I am using Visual Studio with a couple of Qt4 projects and I would like to switch to QtCreator, but keeping the msvc compiler.
After configuring everything in QtCreator I get this linker error:
LNK2001: unresolved external symbol _imp_SysAllocString#4
Any idea about what is going on? I don't get this error if I compile using Visual Studio.
You need to link against OleAut32.dll. Try adding this to your qmake project file:
win32: LIBS += -loleaut32 -lole32
Related
I have a C++ project using Qt5 (also compiles with Qt4) which I want to make available in python (preferable 3.4). In order to do this I use PyQt4 (because of the QtXml module which is, as far as I know, not available in PyQt5 anymore) and sip. This all works perfectly on my linux machine. But unfortunately I need it for windows and can't get it run. What I have done so far:
A very small example without Qt or other dependencies (one function which returns an integer) works. Even with gcc. But after an "bad reloc" error in my project I switched to the MSVC
My python 3.4 was build with "MSC v.1600 32 bit (Intel)" "on win32" so according to What version of Visual Studio is Python on my computer compiled with? I downloaded Qt 5.2.1 MSVC2010 and Microsoft Visual Studio Express 2010 SP1
I assume that the precompiled PyQt4-4.11.2-gpl-Py3.4-Qt5.3.1-x32 should fit
In order to get the sip.h and sipconfig.py file I compiled sip (4.16.3).
From now on I am unsure what to do. I have to admit that I have no knowledge about libraries.
The C++/Qt project is compiled with QtCreator with CONFIG += staticlib and TEMPLATE = lib. The resulting *.lib (here: xml2db.lib) is been copied to the folder where my sip files are (e.g. sipxml2dbcmodule.cpp)
So via the "VS Command Prompt" nmake throws fatal (link) errors. I'm unsure what the needed compiler flags should be or if the staticlib is wrong. My flags are:
LFLAGS = /NOLOGO /DYNAMICBASE /NXCOMPAT /DLL /MANIFEST /MANIFESTFILE:$(TARGET).manifest /SUBSYSTEM:WINDOWS /INCREMENTAL:NO /NODEFAULTLIB:library /LIBPATH:/LIBPATH:C:\Qt\5.2.1\msvc2010\lib
LIBS = /LIBPATH:C:\Python34\libs python34.lib xml2db.lib /LIBPATH:C:\Qt\5.2.1\msvc2010\lib\Qt5Xmld.lib C:\Qt\5.2.1\msvc2010\lib\Qt5Sqld.lib C:\Qt\5.2.1\msvc2010\lib\Qt5Cored.lib
$(TARGET): $(OFILES)
$(LINK) $(LFLAGS) /OUT:$(TARGET) $(OFILES) $(LIBS)
Where target is "myTools.pyd". It results in
sipmyToolscmodule.cpp
sipmyToolsxml2db.cpp
Generating Code...
link /NOLOGO /DYNAMICBASE /NXCOMPAT /DLL /MANIFEST /MANIFESTFILE:myTools
.pyd.manifest /SUBSYSTEM:WINDOWS /INCREMENTAL:NO /NODEFAULTLIB:library /LIBPATH:
C:\Qt\5.2.1\msvc2010\lib /OUT:myTools.pyd sipmyToolscmodule.obj sipmyToolsxml2db
.obj /LIBPATH:C:\Python34\libs python34.lib xml2db.lib /LIBPATH:C:\Qt\5.2.1\msvc
2010\lib\Qt5Xmld.lib C:\Qt\5.2.1\msvc2010\lib\Qt5Sqld.lib C:\Qt\5.2.1\msvc2010\l
ib\Qt5Cored.lib
xml2db.lib(xml2db.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_L
EVEL': value '2' doesn't match value '0' in sipmyToolscmodule.obj
MSVCRTD.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_i
nfo(class type_info const &)" (??0type_info##AAE#ABV0##Z) already defined in LIB
CMT.lib(typinfo.obj)
MSVCRTD.lib(ti_inst.obj) : error LNK2005: "private: class type_info & __thiscall
type_info::operator=(class type_info const &)" (??4type_info##AAEAAV0#ABV0##Z)
already defined in LIBCMT.lib(typinfo.obj)
Creating library myTools.lib and object myTools.exp
LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; u
se /NODEFAULTLIB:library
myTools.pyd : fatal error LNK1169: one or more multiply defined symbols found
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 10.0
\VC\BIN\link.EXE"' : return code '0x491'
Stop.
I would be pleased for an answer or fresh idea. Thanks in advance.
EDIT
I don't know exactly how I solved it but here are a few more hints that helped me to solve it.
Since sip 5 won't have the build system I tried to create a qmake project. To do so I downloaded the pyqt source package and looked at the project files and adjusted it to my needs.
Especially when you are changing the qmake project file it might be usefull to delete the make, object and/or moc files.
The qt version should perfectly match to the pyqt version (actually I don't mean the version itself but the qt version it was compiled for)
Good luck for those who have similiar problems
I'm having trouble to compile VTK 5.10.1 example code in Visual Studio 2010 on Windows 7 64 bit SP1.
First of all, I installed VTK using this tutorial.
No errors occured while installing VTK and the example executables like cone.exe located at C:\VTK5.10.1_cmake\bin\Release are running just fine.
In Visual Studio 2010 I started a new Win32 console application and tested the first example code from this site.
I edited the projekt properties (additional include directories, additional Library directories and additional dependencies).
The linker errors looked like that:
vtktest.obj : error LNK2019: unresolved external symbol ""public: void __thiscall vtkRenderer::AddActor(class vtkProp *)" (?AddActor#vtkRenderer##QAEXPAVvtkProp###Z)" referenced in function "_main".
Most of the the other people with the same error forgot to add the libs to the additional dependencies.
However I added all libs in the C:\VTK5.10.1_bin\lib\vtk-5.10 directory and the opengl32 library. I tried to seperate the libs by a space, a semicolon and a new line.
Then, I read that people are using the shared libraries. I'm not really familiar with dlls. I reinstalled VTK
with shared libraries options turned on and copied the resulting dlls to the System32 directory.
Now, the errors looks slightly different:
vtktest.obj : error LNK2019: unresolved external symbol ""__declspec(dllimport) public: void __thiscall vtkRenderer::AddActor(class vtkProp *)" (__imp_?AddActor#vtkRenderer##QAEXPAVvtkProp###Z)" referenced in function "_main".
Any help would be appriciated!
Nevermind, forgot to change the platform to x64 :/
I'm still new to Qt. In the past I used to download Qt on a computer and install it without any problems and I get immediate access to all Qt SDK resources including QtCreator.
Now, I downloaded Qt SDK 4.8.3 and after some reading I ended up installing Windows SDK 7. Then I extracted Qt files to C:\Qt. I also added C:\Qt\4.8.3\ to the system path. Then I ran configure which is concluded with no errors. Then I attempted to run nmake which failed with the following error:
Generating Code...
link /LIBPATH:"c:\Qt\4.8.3\lib" /LIBPATH:"c:\Qt\4.8.3\lib" /NOLOGO /DYNAMICBASE /NXCOMPAT /BASE:0x67000000 /DEBUG /DLL /MANIFEST /MANIFESTFILE:"tmp\obj\debug_shared\QtCored.intermediate.manifest" /VERSION:4.83 /OUT:....\lib\QtCored4.dll #C:\Users\MELKAM~1\AppData\Local\Temp\nm5A03.tmp
Creating library ....\lib\QtCored4.lib and object ....\lib\QtCored4.exp
LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 10.0
\VC\Bin\amd64\link.EXE"' : return code '0x463'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 10.0
\VC\Bin\amd64\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: 'cd' : return code '0x2'
Stop.
Now I have tried the above twice with no luck. Any pointer where should I look? any suggestions are appreciated.
Thanks.
What are you compiling with? MSVC or mingw? If the former, I have found this link incredibly helpful...
http://www.holoborodko.com/pavel/2011/02/01/how-to-compile-qt-4-7-with-visual-studio-2010/
I have followed his instructions for 64bit and 32bit builds many times.
Edit: You have your qt build configured for a MSVC2010 (1600) build, so it's looking in the "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\Bin\amd64\nmake.exe" directory, which doesn't exist if you only have MSVC2012 (which is version 11.0).
Qt 4.8 doesn't officially support MSVC2012 (yet?), but if you really want to use 2012 then you can try the suggestions at this link. It's complicated, especially if this is your first source build, but seems do-able if you're willing to tinker with the Qt source code.
I had the same issue. the problem was installing visual studio 2012 on a machine with visual studio 2010.
May be this can help https://stackoverflow.com/a/15132209/1933829
Did you run configure from the 64bit tools command tool in vs?
Did you add -platform win32-msvc2010 to the configure commandline (yes even for 64bit builds you need -win32- )
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 am using boost's threading library and have run into linking issues in Visual Studio.
Right now, I'm compiling my VS project with /MT. The library I'm linking against is called libboost_thread-vc100-mt-1_48.lib, which seems to indicate that it, too has been compiled using /MT.
However, if I turn off all /MD related libraries in my linker settings (properties -> Linker -> Input -> Ignore Specific Default Libraries)...
msvcrt.lib
msvcrtd.lib
msvcprt.lib
msvcprtd.lib
Then I get linker errors!
libboost_thread-vc100-mt-1_48.lib(thread.obj) : error LNK2001: unresolved external symbol __imp___gmtime64
libboost_thread-vc100-mt-1_48.lib(thread.obj) : error LNK2001: unresolved external symbol __imp___beginthreadex
How could this be possible just by turning off /MD related libraries? boost::thread should only be linking against libs in /MT (Which should be LIBCMT.LIB, LIBCPMT.LIB). Did I compile boost incorrectly?
BAM! Linker defeated!
It looks like my hunch was right. I didn't compile boost correctly. To emulate /MT with a boost build, you need to link against static runtime libraries (linking to dynamic runtime libraries seems to be the default).
The command to do this (for Release build of boost::thread) was:
.\b2 --with-thread variant=release link=static threading=multi runtime-link=static
Hope this helps someone out there using boost with /MT turned on in their project!