I added some boost stuff* to my code and the linking phase failed with:
error LNK2019: unresolved external symbol _IsolationAwareLoadLibraryA#4 referenced in function "void * __cdecl boost::interprocess::winapi::load_library(char const *)" (?load_library#winapi#interprocess#boost##YAPAXPBD#Z)
Can anyone help me figure this out? kernel32.lib is added in linker settings. I searched for _IsolationAwareLoadLibraryA and it doesn't seem to be present in Windows SDK 6.0A, which I'm using. The project is CLR if that matters.
*the boost stuff are two shared memory headers:
#include <boost/interprocess/shared_memory_object.hpp>
#include <boost/interprocess/mapped_region.hpp>
This functions are part of SDK 7.0A, and they should be inline (so there's no need to specify an .lib file). Try downloading and using a newer SDK, and make sure that ISOLATION_AWARE_ENABLED gets #defined, because this is what triggers the inclusion of those functions. I guess boost should define it by itself though.
It turned out the project I used had a "ISOLATION_AWARE_ENABLED=1" added to preprocessor definitions. Removing it fixed the linker error. Not sure whether this won't cause any other problems though. The disturbing fact is that I'm wasting lots of time just resolving various issues related to building my project with third-party C/C++ libraries.
Related
This question already has answers here:
What is an undefined reference/unresolved external symbol error and how do I fix it?
(39 answers)
Closed 5 years ago.
I tried multiple PDF lybrary and MUPDF is my last chance to build my own small PDF application. But here I also have problems. Before that I had problem with LNK4098: defaultlib 'MSVCRT', but I solved that to set for all MUPDF library /MDd version. Most errors is solved after that, but still I can't to solve this:
error LNK2001: unresolved external symbol "void __cdecl pdfapp_open(struct pdfapp_s *,char *,int)" (?pdfapp_open##YAXPEAUpdfapp_s##PEADH#Z)
//more 3 errors
As MuPDF written on C, I do this:
extern "C" {
#include <pdfapp.h>
#include <mupdf\fitz\context.h>
}
But I get this errors:
error LNK2001: unresolved external symbol pdfapp_open
//more 3 errors
There is only three functions what I use in my application. I checked libs and headers linking, I set my project Debug, x64, /MDd also but I get the same.
Honestly, I can't find this three functons in no one libs. I'm not a expert in programming but I know that functions strings should be finding in libs, doesn't? What does mean this errors in my case?
Either your linker is failing to find the import library for mupdf or you have a name mangling/decoration type issue.
Once you download and build mupdf, there should be an import library for you to link to. Are you linking to it? Look in your project linker settings under Linker >> Input >> Additional Dependencies. Have you added such an import?
If not, add it in. It shouldn't be hard to find. It is likely right next to the mupdf DLL that you downloaded (or built).
Assuming you have added it, your next step is to verify that you are properly finding it. Look at the build output. Are you getting a warning about it? No, change the Linker >> General >> Show Progress to "Display all progress messages" and build again. Is there a warning about the library or function?
Last possibility that I can think of is that the DLL is actually exporting its functions as C++ (i.e. with name decoration), not as extern "C". In that case and your extern "C" brackets don't belong there. Or perhaps vice versa (i.e. maybe you failed to use extern "C" in all places you #include it). I can see that your example uses it but is that all the places?
If you are building the mupdf.DLL be sure it is being built the same way and with the same calling convention as your client code.
I am trying to use CImg library for some image processing task. Using VS 2012 on Windows 7 x64, I am building a project to create dll that I need for my application. I have included the only header file CImg.h from the library. But as soon as I initialize an CImg object, I get bunch of unresolved external symbol errors. One sample error is as follows:
layer.obj : error LNK2019: unresolved external symbol __imp_SetDIBitsToDevice referenced in function "public: struct cimg_library::CImgDisplay & __cdecl cimg_library::CImgDisplay::paint(void)" (?paint#CImgDisplay#cimg_library##QEAAAEAU12#XZ)
Can anyone explain to me what am I doing wrong and how to fix it? (I am a newbie when it comes to C++ terminologies.)
there is nothing other than the header file in the CImg library to link to.
You cannot link to a header file. If it is a header-only library, then you do not need to link anything. You include the header file and the functions it defines are compiled directly. That appears to be the case for CImg; the documentation says it is a self-contained template library that consists of only a single header file. So indeed, all you need to do is include it and you're off to the races.
The unresolved external symbol errors are coming from somewhere else. You have to read the error messages and look at the function names to see where.
A couple of hints:
The __imp_ prefix suggests that you're looking at a Windows API function.
If you didn't know that, you could always ignore the prefix and Google the readable part of the name, in this case, SetDIBitsToDevice. Chances are very good you'll turn up the documentation or at least something that points you in the right direction.
Indeed, in this case, you get right to Microsoft's SDK documentation for the SetDIBitsToDevice function. It's a Windows API function alright, and Microsoft's documentation always tells you what library you need to link to in order to consume it. Look at the bottom of the page:
Header: Wingdi.h (include Windows.h)
Library: Gdi32.lib
DLL: Gdi32.dll
The CImg library header file has obviously already included the Windows.h header file, or you'd have gotten a compile-time error. You're getting a linker error, which means that you have not told the linker to link in the Gdi32.lib library. This is what will allow you to call GDI functions. It is a stub that facilitates calling functions exported from Gdi32.dll.
In general, when building a Windows application, you will want to link with, at minimum, kernel32.lib, user32.lib, and gdi32.lib.
This question contains more information on dealing with undefined symbol errors, and also how to configure your linker. In Visual Studio, go to Project Properties → C/C++ → Linker → Input → Additional Dependencies. Or add #pragma comment(lib, "gdi32.lib") to a source file (your precompiled header is a good place, usually named StdAfx.h).
This function is part of the win32 API, specifically in GDI. You need to change your project settings to link with Gdi32.lib
https://msdn.microsoft.com/en-us/library/windows/desktop/dd162974(v=vs.85).aspx
I'm making a C++ program and I want to use FFmpeg pre-built for x64, which is a C-compiled library.
I'm using this code in order to include its header:
extern "C" {
#include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"
#pragma comment (lib,"G:/Documents/ffmpeg/lib/avcodec.lib")
#pragma comment (lib,"G:/Documents/ffmpeg/lib/avformat.lib")
}
I'm then calling the symbols like I would do for a normal function, for example with av_interleaved_write_frame(out->formatContext, &packet);
However, when I try to compile it with Visual Studio 2015's built-in C++ compiler, I get a lot of error like
Error LNK2019 unresolved external symbol _av_write_trailer referenced in function "void __cdecl closeArenaVideo(struct VideoOutput *)" (?closeArenaVideo##YAXPAUVideoOutput###Z) Sparta2 c:\Users\Théo\documents\visual studio 2015\Projects\Sparta2\Sparta2\video.obj
for basically any of the symbols I'm refering to.
I tried to import everything in Visual Studio, to compile with command-line, to manually put FFmpeg's libraries in the default libraries path, without success.
Thank you in advance!
A typical problem which is hard to understand from quoted linker errors is the problem of referencing wrong .lib files, esp Win32 platform libraries in x64 build and vice versa. The names might be correct, but the set is wrong and then linker takes the #pragma references but ignores the content.
You should make sure that your build platform matches the bitness of referenced library files. This answer has minimalistic project which does build well and you can compare code/references to what you use, and it also mentions bitness problem as well in the very bottom and comments to the answer.
I am trying to statically link this library into my VS C++ project.First I compiled the source as a static lib.Linked it via VS Project properties.The .exe project works fine.Then I read this MS manual on how to compile the static lib into the executable and following the steps outlined there now if I am running the executable I am getting these errors:
Error 3 error LNK2019: unresolved external symbol __imp__glBlendFunc#8
referenced in function _text_buffer_render E:\Documents\visual studio
2012\Projects\XXXXEngine\FreeTypeTest\text-buffer.obj
Error 4 error LNK2019: unresolved external symbol __imp__glBindTexture#8
referenced in function _text_buffer_render E:\Documents\visual studio
2012\Projects\XXXXEngine\FreeTypeTest\text-buffer.obj
To me it seems like GLEW.lib errors.Does it mean I have to link also glew.lib statically as the freetype GL depends on it ?
Also, can I just use the lib with the executable without adding it to references, or it won't work in release build?I am asking it as I am quite confused with how the static linking should be done.I mean,now the executable works without adding the library to the project reference.Then why can't it be used just like this?
To me it seems like GLEW.lib errors
They are not, glBindTexture() is an OpenGL function. The MSDN library page is here. Scroll to the bottom, it shows you the .h file that declares it (you already that right since the compiler didn't complain) and the .lib you need to link.
Right-click your project, Properties, Linker, Input, Additional Dependencies setting. Add opengl32.lib. Or to use the upvoted answer's suggestion, you can inject the linker directive in your source code:
#include <gl\gl.h>
#pragma comment(lib, "opengl32.lib")
Have you tried to pragma mark your library?
Like so:
#pragma comment(lib, "any.lib");
I cannot get GLEW to link correctly with my program.
I have the path correct in my project (I've triple checked), I have tried building from scratch, using the x86 libs (all 4 - the -s, -mxs, etc) AND the x64 libs.
I have tried using the #pragma directive instead of configuring my project in properties.
I am trying to get it as a static lib so no DLLs will be necessary.
I also have GLEW_STATIC defined, as the build instructions advise.
Error message:
OGLInit.obj : error LNK2019: unresolved external symbol _glewInit#0
referenced in function "bool __stdcall vexal::OGLStartup(void)"
(?OGLStartup#vexal##YG_NXZ)
I've even used dumpbin to check that initGlew is there. It is, and it is external.
I've also verified it's found the lib.
Searching
C:\Users\Jake\Documents\Vexal2\vexal\vc9_x86\lib\Debug\GLEW.lib:
I've run out of ideas here. Any help?
Yep. I rebuilt it using the glew_static project.
Just because you built that project doesn't mean you're linking to it.
C:\Users\Jake\Documents\Vexal2\vexal\vc9_x86\lib\Debug\GLEW.lib
That is not the static GLEW library. That is the import library for the DLL version of GLEW. The static GLEW library is called GLEW32s.lib. Link to that.
The problem was the calling convention. I changed the calling convention settings to __stdcall instead of __cdecl, changed _glfwTerminate_atexit( void ) to __cdecl in the GLFW code I had, and then built.
Fixed!