How to get boost.python tutorial example to link with Python3? - visual-studio-2010

I want to use boost.python with python 3.2+ (preferably 3.4) and Visual Studio 2010.
When I try to make the libs\python\example\tutorial example against any Python3 (I have tested 3.0, 3.2 and 3.4) it doesn't link (see below). When I link it against 2.7 it works.
The only change I make between attempts is updating user-config.jam in my home directory.
So it works when user-config.jam is:
# MSVC configuration
using msvc : 10.0 ;
# Python configuration:
using python : 2.7 : C:\\Python27 : C:\\Python27\\include : C:\\Python27\\libs ;
When I run bjam I get:
C:\Boost\boost_1_55_0\libs\python\example\tutorial>bjam
link.jam: No such file or directory
...patience...
...patience...
...found 1678 targets...
...updating 8 targets...
compile-c-c++ bin\msvc-10.0\debug\hello.obj
hello.cpp
msvc.link.dll bin\msvc-10.0\debug\hello_ext.pyd
Creating library bin\msvc-10.0\debug\hello_ext.lib and object bin\msvc-10.0\debug\hello_ext.exp
msvc.manifest.dll bin\msvc-10.0\debug\hello_ext.pyd
common.copy boost_python-vc100-gd-1_55.dll
..\..\..\..\bin.v2\libs\python\build\msvc-10.0\debug\boost_python-vc100-gd-1_55.dll
1 file(s) copied.
common.copy hello_ext.pyd
bin\msvc-10.0\debug\hello_ext.pyd
1 file(s) copied.
capture-output bin\hello.test\msvc-10.0\debug\hello
1 file(s) copied.
**passed** bin\hello.test\msvc-10.0\debug\hello.test
...updated 8 targets...
If I change user-config.jam to:
# MSVC configuration
using msvc : 10.0 ;
# Python configuration:
using python : 3.4 : C:\\Python34 : C:\\Python34\\include : C:\\Python34\\libs ;
and to bjam clean and then bjam I get:
C:\Boost\boost_1_55_0\libs\python\example\tutorial>bjam
link.jam: No such file or directory
...patience...
...patience...
...found 1685 targets...
...updating 9 targets...
compile-c-c++ bin\msvc-10.0\debug\hello.obj
hello.cpp
msvc.link.dll bin\msvc-10.0\debug\hello_ext.pyd
Creating library bin\msvc-10.0\debug\hello_ext.lib and object bin\msvc-10.0\debug\hello_ext.exp
hello.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) struct _object * __cdecl boost::python::detail::init_module(struct PyModuleDef &,void (__cdecl*)(void))" (__imp_?init_module#detail#python#boost##YAPAU_object##AAUPyModuleDef##P6AXXZ#Z) referenced in function _PyInit_hello_ext
bin\msvc-10.0\debug\hello_ext.pyd : fatal error LNK1120: 1 unresolved externals
call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x86 >nul
link /NOLOGO /INCREMENTAL:NO /DLL /DEBUG /MACHINE:X86 /MANIFEST /subsystem:console /out:"bin\msvc-10.0\debug\hello_ext.pyd" /IMPLIB:"bin\msvc-10.0\debug\hello_ext.lib" /LIBPATH:"C:\Python34\libs" #"bin\msvc-10.0\debug\hello_ext.pyd.rsp"
if %ERRORLEVEL% NEQ 0 EXIT %ERRORLEVEL%
...failed msvc.link.dll bin\msvc-10.0\debug\hello_ext.pyd bin\msvc-10.0\debug\hello_ext.lib bin\msvc-10.0\debug\hello_ext.pdb bin\msvc-10.0\debug\hello_ext.pdb...
...removing bin\msvc-10.0\debug\hello_ext.lib
...removing bin\msvc-10.0\debug\hello_ext.pdb
common.copy boost_python-vc100-gd-1_55.dll
..\..\..\..\bin.v2\libs\python\build\msvc-10.0\debug\boost_python-vc100-gd-1_55.dll
1 file(s) copied.
...skipped <p.>hello_ext.pyd for lack of <pbin\msvc-10.0\debug>hello_ext.pyd...
...failed updating 3 targets...
...skipped 1 target...
...updated 2 targets...
Looking online I find a couple of references to this error but no solutions...
Here is the best link:
http://lists.boost.org/boost-build/2011/06/25147.php
I have seen many people talking about using Python3 and boost.python so I must be missing something... Do I need to compile boost specifically for Python 3 somehow?
Help?
/Robert

So through trial and error I found a way that works.
I am not able to recompile a boost library from Python27 to Python34 but if I start from a clean area (i.e freshly 7zipped) and do the following it works (all in a Visual Studio 2010 command prompt):
Make sure you have a user-config.jam file in your home directory with the following content:
# MSVC configuration
using msvc : 10.0 ;
# Python configuration:
using python : 3.4 : C:\\Python34 : C:\\Python34\\include : C:\\Python34\\libs ;
cd C:\Boost\boost_1_55_0
bootstrap
b2 toolset=msvc-10.0 --build-type=complete --with-python --libdir=C:\Boost\lib\i386 install
cd C:\Boost\boost_1_55_0\libs\python\example\tutorial
set lib=c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\LIB;c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\ATLMFC\LIB;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib;C:\Boost\lib\i386;C:\Python34\libs (i.e add Boost Lib to path)
bjam
Modify hello.py to att () around print:
import hello_ext
print(hello_ext.greet())
python hello.py prints hello, world (Note that python here is python 3.4.1 my default install)
So what I still don't know how to solve is how to recompile boost and/or how to support two python version at the same time. Ideas and suggestions are welcomed but at the moment I only need Python3 so I will not investigate that.
Another thing to note is that the pre-compiled headers found online all seem to be 2.7 only. I hope these steps helps someone else!

Related

Compile Apache APR on Windows

The end result is I am trying to compile something that requires the APR from Apache on Windows.
Edit: Tried Visual Studio command line tools for VS2013 & VS2014.
Link for SVN checkout shows 404: http://apr.apache.org/anonsvn.txt
so...
From this link http://apr.apache.org/compiling_win32.html I have downloaded the three files. I unzipped them and renames them as the directory structure suggested.
C:\work\apr\
C:\work\apr-iconv\
C:\work\apr-util\
Moved to the apr-util directory and ran the following make command and received the following errors.
Note there is the comment about "Current versions of APR do not need awk..." but the link does not work, does it matter?
Anybody have any luck compiling this, do I need other lib/include/objects?
nmake -f Makefile.win buildall checkall installall clean
Received the following errors:
<clip>
rc.exe /l 0x409 /fo".\Release\libapriconv.res" /i "./include" /i "../apr/include" /d "NDEBUG" /d "API_VERSION_ONLY" .\libapriconv.rc
Microsoft (R) Windows (R) Resource Compiler Version 6.3.9600.17336
Copyright (C) Microsoft Corporation. All rights reserved.
link.exe #C:\Users\JOHNAT~1\AppData\Local\Temp\nm390A.tmp
Creating library .\Release\libapriconv-1.lib and object .\Release\libapriconv-1.exp
if exist .\Release\libapriconv-1.dll.manifest mt.exe -manifest .\Release\libapriconv-1.dll.manifest -outputresource:.\Release\libapriconv-1.dll;2
echo Helper for Post-build step > ".\Release\postbld.dep"
cd ccs
"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\nmake.exe" -nologo -f Makefile.win all BUILD_MODE="Win32 Release" BIND_MODE=shared adobe-stdenc.c
Creating library ..\Release\iconv\adobe-stdenc.lib and object ..\Release\iconv\adobe-stdenc.exp
adobe-stdenc.obj : error LNK2011: precompiled object not linked in; image may not run
..\Release\iconv\adobe-stdenc.so : fatal error LNK1120: 1 unresolved externals
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\link.EXE"' : return code '0x460'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\nmake.exe"' : return code '0x2'
Stop.
It's a little late, but here is how I fixed it.
In the build\modules.mk.win makefile change line 221 from
$(SILENT)link $(ALL_LDFLAGS) $*.obj $(API_LIBS) /out:$# \
To
$(SILENT)link $(ALL_LDFLAGS) $*.obj $(MODRES).obj $(API_LIBS) /out:$# \
The shared library target will now read:
.c{$(OUTPUT_DIR)}.so:
$(SILENT)cl $(ALL_CFLAGS) /Fo$*.obj /Yuiconv.h /c $<
$(SILENT)link $(ALL_LDFLAGS) $*.obj $(MODRES).obj $(API_LIBS) /out:$# \
/base:#"..\build\BaseAddr.ref",$(#F)
$(SILENT)if exist $#.manifest \
$(SILENT)mt -nologo -manifest $#.manifest -outputresource:$#;2 \
& del "$#.manifest"
$(SILENT)del "$*.exp" & del "$*.lib"
Source: https://gist.github.com/mkhon/01a1536b01e0065ae799
From the apache-apr project site under heading:
Developer Studio Workspace/Microsoft Development Environment IDE Build::
Open the apr-util/aprutil.dsw workspace, and choose either aprutil or libaprutil (for static or dynamic libraries) with the Release or Debug build as the Active Project. aprutil.dsw causes all related projects to be built.
Maybe you overlooked this statement : choose either aprutil or libaprutil as the Active Project...
Then build the active project.

Debugging Qt with Visual Studio

How is it possible to debug Qt 4.8 in Visual Studio 2005?
Building release does work but if i try to debug, I always get this message:
This application has failed to start because the application configuration is incorrect. Review the manifest file for possible errors. Reinstalling the application may fix this problem. For more details, please see the application event log.
How can I fix that? Thank you!
Update
I rebuild Qt for Visual Studio 2005 using configure -platform win32-msvc2005 and jom instead of nmake (damn thats fast) and now get following Errorcode:
The application was unable to start correctly (0xc0150002).Click OK to close the application.
Update2
How can I fix the DLLs and error messages?
Dependency Walker:
Missing DLLs
MSVCP90D.DLL
MSVCR90D.DLL
API-MS-WIN-APPMODEL-RUNTIME-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-ERROR-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-ROBUFFER-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-STRING-L1-1-0.DLL
API-MS-WIN-SHCORE-SCALING-L1-1-1.DLL
DCOMP.DLL
IESHIMS.DLL
Error messages
Error: The Side-by-Side configuration information for "c:\qt\4.8.6\bin\QTGUID4.DLL" contains errors.
Error: At least one required implicit or forwarded dependency was not found.
Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module.
Error: Modules with different CPU types were found.
Warning: At least one delay-load dependency module was not found.
Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.
Update 3
I now started from scratch:
Install qt-opensource-windows-x86-vs2008-4.8.6.exe (building from qt-everywhere-opensource-src-4.8.6.zip would even cause release mode not to work anymore, cannot find QtGuid4.lib and QtGui4.lib, but with building from installed Qt it finds the libs)
Install qt-vs-addin-1.1.11-opensource.exe
jom distclean "Error: File Makefile doesn't exist exit."
jom confclean "Error: File Makefile doesn't exist exit."
configure -platform win32-msvc2005
jom
Last few output lines of jom:
C:\Qt\4.8.6>jom
[...]
qimageiohandler.cpp
qimagereader.cpp
qimagewriter.cpp
qpaintengine_pic.cpp
qkeymapper_win.cpp
qiconloader.cpp
Code wird generiert...
Code wird generiert...
qimage.cpp
jom: C:\Qt\4.8.6\src\gui\Makefile.Release [tmp\obj\release_shared\qguiplatformpl
ugin.obj] Error 2
cl -c -FIqt_gui_pch.h -Yuqt_gui_pch.h -Fptmp\obj\release_shared\QtGui_pc
h.pch -nologo -Zm200 -Zc:wchar_t- -O2 -MD -W3 -w34100 -w34189 -GR -EHsc -DQT_SHA
RED -DQT_THREAD_SUPPORT -DUNICODE -DWIN32 -DQT_BUILD_GUI_LIB -DQT_NO_USING_NAMES
PACE -DQT_MAKEDLL -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT3_SUPPORT -
DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -D_USE_MATH_DEFINES -DQT_NO_DIRECTDRAW -D
QT_USE_BUNDLED_LIBPNG -DPNG_NO_ASSEMBLER_CODE -DQT_NO_CUPS -DQT_NO_LPR -DQT_NO_O
PENTYPE -DQT_NO_STYLE_MAC -DQT_NO_STYLE_GTK -DQT_NO_STYLE_WINDOWSCE -DQT_NO_STYL
E_WINDOWSMOBILE -DQT_NO_STYLE_S60 -DQT_NO_EGL -DQ_INTERNAL_QAPP_SRC -DQT_NO_DIRE
CTWRITE -DQT_DLL -DQT_NO_DEBUG -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_
HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DNDEBUG -I"..\..\include\QtCore" -I"..
\..\include" -I"..\..\include\QtGui" -I"tmp\rcc\debug_shared" -I"tmp" -I"..\3rdp
arty\wintab" -I"image" -I"..\3rdparty\libpng" -I"..\3rdparty\zlib" -I"..\3rdpart
y\zlib" -I"..\3rdparty\harfbuzz\src" -I"dialogs" -I"..\..\include\ActiveQt" -I"t
mp\moc\release_shared" -I"." -I"..\..\mkspecs\win32-msvc2005" -Fotmp\obj\release
_shared\ #C:\Users\fpieske\AppData\Local\Temp\qpicture.obj.5884.19719.jom
qpicture.cpp
qpictureformatplugin.cpp
qpixmap.cpp
qpixmapdata.cpp
Code wird generiert...
Code wird generiert...
jom: C:\Qt\4.8.6\src\gui\Makefile [release-all] Error 2
jom: C:\Qt\4.8.6\Makefile [sub-gui-make_default-ordered] Error 2
C:\Qt\4.8.6>
I got it! Was about to quit trying to debug with Visual Studio and use Qt Creator instead. While reading how to configure Qt Creator i read about installing Windows SDK. Well debugging with Qt Creator still does not work (Unknown debugger type "No Engine") but installing Windows SDK solved my debugging problem in Visual Studio!
Try the following:
Open a command prompt and traverse to the directory where your Qt .pro file resides.
Run the following command - qmake -tp vc {name of the project file}.
Open Visual Studio and browse to the same directory. There should now be a generated VS project inside it.
Open the project.
In VS Project Properties|Configuration Properties|Debugging set any Environment or Command Line Arguments.
Build a debug version of the application and run it.
Save solution.
If you encounter build problems it may be that there were incorrectly escaped strings (at least as far as VS is concerned) in the project file. For example
DEFINES+=\"DEFINE_NAME=$$quote(\\"SomeString\\")\"
Will need to be modifed temporarily to this:
DEFINES+=\"DEFINE_NAME=$$quote(\"\"\"SomeString\"\"\")\"

build boost python 3.4 64 bit

I am trying to follow the tutorial in Boost.python.
My environment is in the title.
When I try the bjam I receive the following error:
C:\local\boost_1_57_0\libs\python\example\tutorial>bjam.exe
address-model=64 ...patience... ...patience... ...found 1894
targets... ...updating 6 targets... msvc.link.dll
bin\msvc-12.0\debug\address-model-64\threading-multi\hello_ext.pyd
Creating library
bin\msvc-12.0\debug\address-model-64\threading-multi\hello_e xt.pdb
and object
bin\msvc-12.0\debug\address-model-64\threading-multi\hello_ext .exp
LINK : fatal error LNK1207: incompatible PDB format in
'C:\local\boost_1_57_0\li
bs\python\example\tutorial\bin\msvc-12.0\debug\address-model-64\threading-multi\
hello_ext.pdb'; delete and rebuild
call "C:\Users\Navid\AppData\Local\Temp\b2_msvc_12.0_vcvarsall_x86_amd64
.cmd" >nul link /NOLOGO /INCREMENTAL:NO /DLL /NOENTRY /DEBUG
/MACHINE:X64 /MANIFEST /subsys tem:console
/out:"bin\msvc-12.0\debug\address-model-64\threading-multi\hello_ext
.pyd"
/IMPLIB:"bin\msvc-12.0\debug\address-model-64\threading-multi\hello_ext.pd
b" /LIBPATH:"C:\Python34\libs"
#"bin\msvc-12.0\debug\address-model-64\threadin
g-multi\hello_ext.pyd.rsp"
if %ERRORLEVEL% NEQ 0 EXIT %ERRORLEVEL%
...failed msvc.link.dll
bin\msvc-12.0\debug\address-model-64\threading-multi\hel lo_ext.pyd
bin\msvc-12.0\debug\address-model-64\threading-multi\hello_ext.pdb bi
n\msvc-12.0\debug\address-model-64\threading-multi\hello_ext.pdb...
...removing
bin\msvc-12.0\debug\address-model-64\threading-multi\hello_ext.pdb
...skipped hello_ext.pyd for lack of
hello_ext.pyd... copy
bin\hello.test\msvc-12.0\debug\address-model-64\threading-multi\hello.py
hello.py
1 file(s) copied. 2to3 bin\hello.test\msvc-12.0\debug\address-model-64\threading-multi\hello.py
'2to3' is not recognized as an internal or external command, operable
program or batch file. '2to3' is not recognized as an internal or
external command, operable program or batch file.
2to3 -wn --no-diffs "bin\hello.test\msvc-12.0\debug\address-model-64\threadi
ng-multi\hello.py"
2to3 -dwn --no-diffs "bin\hello.test\msvc-12.0\debug\address-model-64\thread
ing-multi\hello.py"
...failed 2to3
bin\hello.test\msvc-12.0\debug\address-model-64\threading-multi\h
ello.py... ...removing
bin\hello.test\msvc-12.0\debug\address-model-64\threading-multi\hell
o.py ...skipped
hel
lo for lack of
hello.py... ...failed updating 3 targets... ...skipped 3 targets...
I made sure .\b2 adress-model=64 and \turorial>bjam address-model=64
The user-config is also configurd for
MSVC configuration.
using msvc : 12.0 ;
Python configuration.
Configure specific Python version. using python : 3.4 : C:\python34 : C:\Python34\include : C:\Python34\libs ;
I want to talk about how to correct the '2to3' is not recognized as an internal or external command, operable program or batch file. It means that 2to3 is not in your path.
In order to add it to your path, follow Python 2to3 windows CMD. Follow the last but one answer

Could not locate OIS using CMake and Makefiles

So I'm trying to compile a simple Ogre3D project:
C:\OgreSDK\Projects\Physics> cmake -G "MinGW Makefiles" ./
-- Looking for OGRE...
-- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
-- Found Ogre Ghadamon (1.9.0)
-- Found OGRE: optimized;C:/OgreSDK/lib/Release/OgreMain.lib;debug;C:/OgreSDK/lib/Debug/OgreMain_d.lib
-- Looking for OGRE_Paging...
-- Found OGRE_Paging: optimized;C:/OgreSDK/lib/Release/OgrePaging.lib;debug;C:/OgreSDK/lib/debug/OgrePaging_d.lib
-- Looking for OGRE_Terrain...
-- Found OGRE_Terrain: optimized;C:/OgreSDK/lib/Release/OgreTerrain.lib;debug;C:/OgreSDK/lib/debug/OgreTerrain_d.lib
-- Looking for OGRE_Property...
-- Found OGRE_Property: optimized;C:/OgreSDK/lib/Release/OgreProperty.lib;debug;C:/OgreSDK/lib/debug/OgreProperty_d.lib
-- Looking for OGRE_RTShaderSystem...
-- Found OGRE_RTShaderSystem: optimized;C:/OgreSDK/lib/Release/OgreRTShaderSystem.lib;debug;C:/OgreSDK/lib/debug/OgreRTShaderSystem_d.lib
-- Looking for OGRE_Volume...
-- Found OGRE_Volume: optimized;C:/OgreSDK/lib/Release/OgreVolume.lib;debug;C:/OgreSDK/lib/debug/OgreVolume_d.lib
-- Looking for OGRE_Overlay...
-- Found OGRE_Overlay: optimized;C:/OgreSDK/lib/Release/OgreOverlay.lib;debug;C:/OgreSDK/lib/debug/OgreOverlay_d.lib
-- Looking for OIS...
-- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
-- Could not locate OIS
CMake Error at C:/OgreSDK/CMake/FindPkgMacros.cmake:120 (message):
Required library OIS not found! Install the library (including dev
packages) and try again. If the library is already installed, set the
missing variables manually in cmake.
Call Stack (most recent call first):
C:/OgreSDK/CMake/FindOIS.cmake:82 (findpkg_finish)
CMakeLists.txt:60 (find_package)
-- Configuring incomplete, errors occurred!
See also "C:/OgreSDK/Projects/Physics/CMakeFiles/CMakeOutput.log".
I checked, in the OgreSDK/bin folder I can see a OIS(_d).dll. If I try to setup a var OIS_HOME which point to a folder with dll folder within the ois.dll, it doesn't work either.
EDIT
Here is a gist with all env vars listed https://gist.github.com/vinz243/0eea7dd96db785d6a4e3
EDIT 2
After some attempts I edited the findOIS.cmake like this:
#-------------------------------------------------------------------
# This file is part of the CMake build system for OGRE
# (Object-oriented Graphics Rendering Engine)
# For the latest info, see http://www.ogre3d.org/
#
# The contents of this file are placed in the public domain. Feel
# free to make use of it in any way you like.
#-------------------------------------------------------------------
# - Try to find OIS
# Once done, this will define
#
# OIS_FOUND - system has OIS
# OIS_INCLUDE_DIRS - the OIS include directories
# OIS_LIBRARIES - link these to use OIS
# OIS_BINARY_REL / OIS_BINARY_DBG - DLL names (windows only)
include(FindPkgMacros)
findpkg_begin(OIS)
# Get path, convert backslashes as ${ENV_${var}}
getenv_path(OIS_HOME)
getenv_path(OGRE_SDK)
getenv_path(OGRE_HOME)
getenv_path(OGRE_SOURCE)
getenv_path(OGRE_DEPENDENCIES_DIR)
# construct search paths
# set(OIS_PREFIX_PATH "C:\\OgreSDK\\bin")
# create_search_paths(OIS)
# redo search if prefix path changed
message(STATUS OIS_PREFIX_PATH ": " ${OIS_PREFIX_PATH})
clear_if_changed(OIS_PREFIX_PATH
OIS_LIBRARY_FWK
OIS_LIBRARY_REL
OIS_LIBRARY_DBG
OIS_INCLUDE_DIR
)
set(OIS_LIBRARY_NAMES OIS)
get_debug_names(OIS_LIBRARY_NAMES)
use_pkgconfig(OIS_PKGC OIS)
# For OIS, prefer static library over framework (important when referencing OIS source build)
set(CMAKE_FIND_FRAMEWORK "LAST")
findpkg_framework(OIS)
if (OIS_HOME)
# OIS uses the 'includes' path for its headers in the source release, not 'include'
set(OIS_INC_SEARCH_PATH ${OIS_INC_SEARCH_PATH} ${OIS_HOME}/includes)
endif()
if (APPLE AND OIS_HOME)
# OIS source build on Mac stores libs in a different location
# Also this is for static build
set(OIS_LIB_SEARCH_PATH ${OIS_LIB_SEARCH_PATH} ${OIS_HOME}/Mac/XCode-2.2/build)
endif()
find_path(OIS_INCLUDE_DIR NAMES OIS.h HINTS "C:\\OgreSDK\\include\\OIS" PATH_SUFFIXES OIS)
find_library(OIS_LIBRARY_REL NAMES ${OIS_LIBRARY_NAMES} HINTS "C:\\OgreSDK\\lib\\Release" PATH_SUFFIXES Release RelWithDebInfo MinSizeRel)
find_library(OIS_LIBRARY_DBG NAMES ${OIS_LIBRARY_NAMES_DBG} HINTS "C:\\OgreSDK\\lib\\debug" PATH_SUFFIXES Debug)
make_library_set(OIS_LIBRARY)
if (WIN32)
set(OIS_BIN_SEARCH_PATH "C:\\OgreSDK\\bin")
find_file(OIS_BINARY_REL NAMES "OIS.dll" HINTS ${OIS_BIN_SEARCH_PATH}
PATH_SUFFIXES "" Release RelWithDebInfo MinSizeRel)
find_file(OIS_BINARY_DBG NAMES "OIS_d.dll" HINTS ${OIS_BIN_SEARCH_PATH}
PATH_SUFFIXES "" Debug )
endif()
mark_as_advanced(OIS_BINARY_REL OIS_BINARY_DBG)
findpkg_finish(OIS)
# add parent of OIS folder to support OIS/OIS.h
add_parent_dir(OIS_INCLUDE_DIRS OIS_INCLUDE_DIR)
# Reset framework finding
set(CMAKE_FIND_FRAMEWORK "FIRST")
And this is what is defined in CMakeCache.txt:
//Path to a file.
OIS_BINARY_DBG:FILEPATH=C:/OgreSDK/bin/Debug/OIS_d.dll
//Path to a file.
OIS_BINARY_REL:FILEPATH=C:/OgreSDK/bin/Release/OIS.dll
//x
OIS_INCLUDE_DIR:PATH=C:/OgreSDK/include/OIS
//x
OIS_LIBRARY_DBG:FILEPATH=OIS_LIBRARY_DBG-NOTFOUND
//x
EDIT 3
I edited the CMakeCache like this:
OIS_BINARY_DBG:FILEPATH=C:/OgreSDK/bin/Debug/OIS_d.dll
//Path to a file.
OIS_BINARY_REL:FILEPATH=C:/OgreSDK/bin/Release/OIS.dll
//x
OIS_INCLUDE_DIR:PATH=C:/OgreSDK/include/OIS
//x
OIS_LIBRARY_DBG:FILEPATH=C:/OgreSDK/lib/Debug/OIS_d.lib
//x
OIS_LIBRARY_FWK:STRING=NOTFOUND
//x
OIS_LIBRARY_REL:FILEPATH=C:/OgreSDK/lib/Debug/OIS.lib
And when I run make:
λ make
Scanning dependencies of target OgreApp
[ 50%] Building CXX object CMakeFiles/OgreApp.dir/BaseApplication.cpp.obj
[100%] Building CXX object CMakeFiles/OgreApp.dir/TutorialApplication.cpp.obj
make[2]: *** No rule to make target « C:/OgreSDK/lib/Debug/OIS.lib »,required for « dist/bin/OgreApp.exe ». Stop.
make[1]: *** [CMakeFiles/OgreApp.dir/all] Error 2
make: *** [all] Error2
EDIT 4: OK, i managed to run cmake. But this is what I get when bulding VS 2013 and v100 compiler:
2> TutorialApplication.cpp
2> Génération de code en cours...
2>BaseApplication.obj : error LNK2019: external symbol unresolved "class boost::system::error_category const & __cdecl boost::system::generic_category(void)" (?generic_category#system#boost##YAABVerror_category#12#XZ) référencé dans la fonction "void __cdecl boost::system::`dynamic initializer for 'posix_category''(void)" (??__Eposix_category#system#boost##YAXXZ)
2>TutorialApplication.obj : error LNK2001: external symbol unresolved "class boost::system::error_category const & __cdecl boost::system::generic_category(void)" (?generic_category#system#boost##YAABVerror_category#12#XZ)
2>Bas**eApplication.obj : error LNK2019: external symbol unresolved "class boost::system::error_category const & __cdecl boost::system::system_category(void)" (?system_category#system#boost##YAABVerror_category#12#XZ) référencé dans la fonction "void __cdecl boost::system::`dynamic initializer for 'native_ecat''(void)" (??__Enative_ecat#system#boost##YAXXZ)
2>TutorialApplication.obj : error LNK2001: external symbol unresolved "class boost::system::error_category const & __cdecl boost::system::system_category(void)" (?system_category#system#boost##YAABVerror_category#12#XZ)
2>C:\OgreSDK\Projects\Physics\build_win32\Debug\OgreApp_d.exe : fatal error LNK1120: 2 unresolved externals
========== Régénération globale : 1 a réussi, 1 a échoué, 0 a été ignoré ==========
EDIT 5
I'm building Ogre w/ VS 2013 and Boost. Successfully built OgreDeps and Ogre itself, but when running the SampleDemo.exe, it said that D3DCOMPILER_47.dll was missing, but finally found it in Steam folder. now I'm trying to recompile my project
EDIT #6
I compiled boost and generated the project. I opened it in VS 2013 and built ALL_BUILD successfully!!!! But how do I run it? The button Debug is named Attach... and when I build INSTALL task it gives me this in both debug and release
4>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppCommon.targets(132,5): error MSB3073: The command "setlocal
4>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppCommon.targets(132,5): error MSB3073: "C:\Program Files (x86)\CMake\bin\cmake.exe" -DBUILD_TYPE=Debug -P cmake_install.cmake
4>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppCommon.targets(132,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd
4>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppCommon.targets(132,5): error MSB3073: :cmEnd
4>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppCommon.targets(132,5): error MSB3073: endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
4>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppCommon.targets(132,5): error MSB3073: :cmErrorLevel
4>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppCommon.targets(132,5): error MSB3073: exit /b %1
4>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppCommon.targets(132,5): error MSB3073: :cmDone
4>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppCommon.targets(132,5): error MSB3073: if %errorlevel% neq 0 goto :VCEnd
4>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppCommon.targets(132,5): error MSB3073: :VCEnd" stopped with code 1.
EDIT #7
OK VS 2013 was generating the OgreApp.exe (or OgreApp_d) in dist. Copied every Ogre dll file in this folder and ran the exe and it worked :) Thank you guys for all your help. To conclude, the solution was rebuilding Ogre with the VS version I wanted to use
Why don't you wish to install pkg-config for Windows first? It would save you from a manual hacking of the CMakefile.txt-s.
The last error you've got is due to missing (proper) linker flags for linking Boost.System library. Likely, one or several of the libraries being linked in also require Boost.System, and this dependency isn't resolved automatically. Typically pkg-config is used to handle the dependecies, but since you're doing-it-yourself, you should manually add the library dependency using imported library target. See this tutorial to get the idea how to properly include external pre-existing libraries to the build chain of your project.
Actually the standard way to define required Boost dependencies in CMakeLists.txt looks like this:
find_package(Boost 1.50 COMPONENTS program_options locale REQUIRED)
with the subsequent
include_directories(${Boost_INCLUDE_DIRS})
add_executable(an_executable ${AN_EXE_SOURCES})
target_link_libraries(an_executable
...
${Boost_LIBRARIES}
)
please note that at least some linkers (e.g. GNU ld) can't re-order a given library list, so if your application demand LibA and LibB, and LibB in turn depends on LibA, than LibB should go first in the linkers library list (if both LibA and LibB depend on each other, than one of these libraries should be included twice). I'm not sure that the problem is actual for Microsoft VC++ Linker, but it's worth mentioning.
Upd: #Vinz243 had to rebuild the OGRE library to get it properly linked against the test application.

How to compile (and link) a python module using PyQt (and sip) under windows

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

Resources