On compiling GOBJECT in Visual Studio, I came across below two
errors:
Error 5 error LNK1120: 1 unresolved externals C:\gtk_compilation\glib\glib-2.46.0\build\win32\vs12\Debug\Win32\bin\gobject-2-vs12.dll gobject
Error 4 error LNK2019: unresolved external symbol ___chkstk_ms referenced in function _ffi_call C:\gtk_compilation\glib\glib-2.46.0\build\win32\vs12\libffi.lib(ffi.o) gobject
I recompiled the libffi using the procedure described here but with
extra flags given to ./configure like below.
cflags="-fno-stack-check -fno-stack-protector -mno-stack-arg-probe"
which i hope will get rid of the ___chkstk_ms invocations.
After make and make install of libffi, I renamed the libffi.a to libffi.lib and libffi.dll.a to libffi.dll and copied them to appropriate directories.
Then I re-build the gobject project in visual studio and I got the same error
which I mentioned in the beginning. :(
Edit:
From this post, I guess the problem's root is that I am using two compilers. But i don't see a way to get around it. I tried to compile
the libffi using Visual Studio Projects available, but hours of efforts
were in vain.
I resolved this using the MSVC build of Libffi found in the Github project.
However, you need to change the line#606 from
sizet z = (*p_arg)->size;
to
unsigned long long z = (*p_arg)->size;
because the typedef is not (for some reason effective here).
Related
I'm trying to link a Windows executable that depends on a several static libraries (some of which I have built, some of which I have not). When I do the link, I get a flock of errors like:
LIBCMT.lib(mlock.obj) : error LNK2005: _unlock already defined in MSVCRT.lib(MSVCR100.dll)
which is the classic /MD vs. /MT problem (whether the C runtime is statically or dynamically linked). I tried the easy solution first, adding the linker flags
/nodefaultlib:libcmt /nodefaultlib:libcpmt
but that just gave different errors:
msvcprt.lib(MSVCP100.dll) : error LNK2005: "public: __cdecl std::_Locinfo::~_Locinfo(void)" (??1_Locinfo#std##QEAA#XZ) already defined in gtest.lib(gtest-all.cc.obj)
gtest.lib(gtest-all.cc.obj) : error LNK2001: unresolved external symbol "private: static int std::locale::id::_Id_cnt" (?_Id_cnt#id#locale#std##0HA)
I've gone through the libraries I'm building, and as far as I can tell I'm building them all /MD. I say "as far as I can tell" because some of them are third-party libraries that come with their own makefiles so I don't have complete control over the build process..
I don't think "depends" works on libraries (only EXEs and DLLs), is there a tool that would let me look at the various libraries I'm linking in, and see which one is bringing in libcmt when I want to be using msvcrt instead?
I have had the same problem and I used dumpbin ( http://msdn.microsoft.com/en-us/library/z66yd3h6.aspx ) with /DIRECTIVES options on the libs. It will show a number of /DEFAULTLIB sections, each one is another lib that your lib try to use. Dumpbin needs to run from the Visual Studio command promt.
dumpbin /DIRECTIVES liblua52.lib
I had 100+ libs with all the solution configurations and platforms so I made a python 2.7 script (crtdisplay.py) to do it for me. It can be found on my bitbucket repository at https://bitbucket.org/vimarina/ctrlcv/src/57b7ddca15b5c7fefddcf20ffcea0633223a4bd6/crtdisplay . Put it in the root directory of your libs. Not much error checking in that code so do not be surprised if it fails :). I used Visual Studio 2010 so might fail on other versions of Visual Studio.
crtdisplay.py > info.txt
I'm getting the following (and many more) errors when attempting to link my project statically with boost.log on MSVC 10.0:
1>libboost_log-vc100-mt-gd-1_53.lib(attribute_name.obj) : error
LNK2001: unresolved external symbol "**__declspec(dllimport)** public:
__thiscall std::_Container_base::~_Container_base(void)" (__imp_??1_Container_base#std##QAE#XZ)
1>libboost_log-vc100-mt-gd-1_53.lib(text_file_backend.obj) : error
LNK2001: unresolved external symbol "**__declspec(dllimport)** public:
__thiscall std::_Container_base::~_Container_base(void)" (__imp_??1_Container_base#std##QAE#XZ)
Note that the project is linking also to boost system, filesystem, and thread libraries.
1> Searching ../lib/\libboost_system-vc100-mt-gd-1_53.lib:
1> Searching ../lib/\libboost_date_time-vc100-mt-gd-1_53.lib:
1> Searching ../lib/\libboost_regex-vc100-mt-gd-1_53.lib:
1> Searching ../lib/\libboost_thread-vc100-mt-gd-1_53.lib:
1> Searching ../lib/\libboost_chrono-vc100-mt-gd-1_53.lib:
1> Searching ../lib/\libboost_log-vc100-mt-gd-1_53.lib:
1> Searching ../lib/\libboost_filesystem-vc100-mt-gd-1_53.lib:
My project does not define the BOOST_ALL_DYN_LINK or BOOST_LOG_DYN_LINK macros, so I was not expecting to see the __declspec signatures, which I am thinking is the ultimate problem. Am I missing something required to properly link this library statically?
Update
I removed precompiled headers on my project and performed a "clean", and everything linked fine. Is it possible that precompiled headers were somehow causing the project to link statically to CRT?
You may need link log_setup firstly and then log before filesystem and so on, this was boost link code in my CMakeLists.txt:
set(USED_BOOST_LIBS ${Boost_LOG_SETUP_LIBRARY} ${Boost_LOG_LIBRARY}
${Boost_FILESYSTEM_LIBRARY}
${Boost_SYSTEM_LIBRARY} ${Boost_DATE_TIME_LIBRARY}
${Boost_THREAD_LIBRARY} ${Boost_REGEX_LIBRARY}
)
...
target_link_libraries(myexe ${USED_BOOST_LIBS})
It works fine with me both on MSVC 14.0 and gcc 4.8.You can try it.
I'm using CMake to build a Qt based application of mine on Windows with Visual Studio 2010 Express. When configuring with cmake I get the following error:
System runtime library file does not exists:
'MSVC10_REDIST_DIR-NOTFOUND/x86/Microsoft.VC100.CRT/msvcp100.dll
System runtime library file does not exists:
'MSVC10_REDIST_DIR-NOTFOUND/x86/Microsoft.VC100.CRT/msvcr100.dll
Then when I try to compile, I'm getting this error (both trying in Visual Studio, and with msbuild):
MSVCRT.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain#16 referenced in function ___tmainCRTStartup
C:\Users\Kurtis\sandbox\UDJ-Desktop-Client\build\src\Release\UDJ.exe : fatal error LNK1120: 1 unresolved externals
I determined that Microsoft Visual C++ 2010 Express doesn't come with the redistributable that I need. So I went to Microsoft's website to download the redistributable (both for x86 and x64). However, after installing it, I'm still getting the above configure and compile errors. Does anyone know what I'm doing wrong, or how to fix my problem?
_WinMain#16 is the entry point of a Windows GUI application, so either it's missing from your source code, or you're not writing a GUI application, in which case your linker flags are incorrect.
Since you're using qt, make sure you have the QtMain Library being linked with your project. You can do this by adding it in your call to Find_Package like so:
find_package(Qt4 4.7.0 COMPONENTS QtMain QtCore QtGui QtSQL Phonon REQUIRED)
I've been attempting to install glew and freeglut to use with Visual Studio 2010. I followed this guide and have backtracked a few times to make sure I followed it correctly but I still get the following errors when I try and compile the example code at the end:
Error 1 error LNK2019: unresolved external symbol _imp_glutMainLoop#0 referenced in function _main c:\Users\Esteban\documents\visual studio 2010\Projects\Chapter 1 Project\Chapter 1 Project\main.obj Chapter 1 Project
Error 2 error LNK2019: unresolved external symbol _imp_glutDisplayFunc#4 referenced in function _InitWindow c:\Users\Esteban\documents\visual studio 2010\Projects\Chapter 1 Project\Chapter 1 Project\main.obj Chapter 1 Project
Error 3 error LNK2019: unresolved external symbol _imp_glutReshapeFunc#4 referenced in function _InitWindow c:\Users\Esteban\documents\visual studio 2010\Projects\Chapter 1 Project\Chapter 1 Project\main.obj Chapter 1 Project
Error 4 error LNK2019: unresolved external symbol _imp_glutInitDisplayMode#4 referenced in function _InitWindow c:\Users\Esteban\documents\visual studio 2010\Projects\Chapter 1 Project\Chapter 1 Project\main.obj Chapter 1 Project
and more just like those. I don't know if its a problem but originally I accidentally grabbed the 64bit version. I realized my mistake and overwrote the files with the 32bit versions, then cleaned and attempted the build again with the same result.
Are you sure that you have done "Step 6: Project Settings (Linker)" in linked guide correctly? It seems that the linker is unable to find symbols that are defined in those libraries (glew and glut32.lib). Also make sure that the Visual Studio knows where to find those libraries (Project->Properties->Configuration properties->VC++ Directories->Library Directories).
All the unresolved external symbols should be found in freeglut.lib. Are you sure that you are properly linking to this library?
Instead of trying to accomplish this in the you could just insert the following line of code in one of your header files:
#pragma comment(lib, "freeglut.lib")
I had this problem too. It turns out I was using the express version of visual studios, so I had to download microsoft sdk to get 64bit openGL libraries. Basically, I found this guide more helpful: http://www.cs.uregina.ca/Links/class-info/315/WWW/Lab1/GLUT/windows.html
I have a large and complicated project that is finally getting unit tests. I've built googleTest 1.6.0 locally with Visual Studio 2010, the project files built with cmake as the README specifies.
This project has many dependent libraries that are statically and dynamically linked. Many of them proprietary. All attempts to link generate 220 such errors. Here is a sampling:
msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: void __cdecl std::_Container_base12::_Orphan_all(void)" (?_Orphan_all#_Container_base12#std##QEAAXXZ) already defined in gtest.lib(gtest-all.obj)
libcpmtd.lib(cerr.obj) : error LNK2005: "protected: char * __cdecl std::basic_streambuf >::_Gndec(void)" (?_Gndec#?$basic_streambuf#DU?$char_traits#D#std###std##IEAAPEADXZ) already defined in msvcprtd.lib(MSVCP100D.dll)
LIBCMTD.lib(setlocal.obj) : error LNK2005: _configthreadlocale already defined in MSVCRTD.lib(MSVCR100D.dll)
LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library
LINK : warning LNK4098: defaultlib 'LIBCMTD' conflicts with use of other libs; use /NODEFAULTLIB:library
fatal error LNK1169: one or more multiply defined symbols found
I've tried the /NODEFAULTLIB flag, and I've tried to ignore just msvcprtd.lib, MSVCRTD.lib, and LIBCMTD.lib, as suggested, but then I suffer from unresolved symbols...
Both the project and googleTest are compiled with x64, /MP, /MDd, and no /clr.
I've been playing around with compiler flags, wondering if there's some sort of version mismatch. Dumpbin, to the extent with which I understand it, hasn't hinted anything I might understand. I was hoping for an er
It looks like your question is answered in Google Talk's FAQ. Make sure all your libraries use the /MD(d) setting.
You may get a number of the following linker error or warnings if you attempt to link your test project with the Google Test library when your project and the are not built using the same compiler settings.
LNK2005: symbol already defined in object
LNK4217: locally defined symbol 'symbol' imported in function 'function'
LNK4049: locally defined symbol 'symbol' imported
The Google Test project (gtest.vcproj) has the Runtime Library option set to /MT (use multi-threaded static libraries, /MTd for debug). If your project uses something else, for example /MD (use multi-threaded DLLs, /MDd for debug), you need to change the setting in the Google Test project to match your project's.
To update this setting open the project properties in the Visual Studio IDE then select the branch Configuration Properties | C/C++ | Code Generation and change the option "Runtime Library". You may also try using gtest-md.vcproj instead of gtest.vcproj.