Author Topic: [MinGW]libboost_python-mgw34-mt-d-1_39.lib is not being linked.  (Read 9112 times)

Offline PJani

  • Single posting newcomer
  • *
  • Posts: 8
Hy im having trouble linking boost python .lib library file in codeblocks. I get undefinited references error, i have the same error with other .lib files. All libraries were build with mingw.
I was working on other projects and i had the same problems with all .lib files not just from boost.
Is this problem of a mingw(not being able to link .lib) or with .lib libraries?

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: [MinGW]libboost_python-mgw34-mt-d-1_39.lib is not being linked.
« Reply #1 on: July 04, 2009, 05:30:26 am »
It is most likely user error; note, without the error message you can not get much help. And, this is most likely NOT the correct forum to get help anyways.

The problem is an MinGW linker issue and most likely not really related to Code::Blocks except that you have not added the correct library or added it in the wrong order or place.

Tim S
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline PJani

  • Single posting newcomer
  • *
  • Posts: 8
Re: [MinGW]libboost_python-mgw34-mt-d-1_39.lib is not being linked.
« Reply #2 on: July 04, 2009, 12:56:36 pm »
Sory i totaly forgot to add error messages...
Quote
obj\Debug\main.o||In function `main': |
C:\Documents and Settings\PJani\Desktop\SandBox\test_boost_py\main.cpp|14|undefined reference to `_imp___ZN5boost6python6importENS0_3strE'|
C:\Documents and Settings\PJani\Desktop\SandBox\test_boost_py\main.cpp|20|undefined reference to `_imp___ZN5boost6python4execENS0_3strENS0_3api6objectES3_'|
obj\Debug\main.o||In function `ZN5boost6python3api9slice_nilD1Ev': |
)]+0x14)||undefined reference to `_imp___ZN5boost6python6detail8str_baseC2EPKc'|
)]+0x1c)||undefined reference to `_imp___ZN5boost6python3api7getattrERKNS1_6objectEPKc'|
||=== Build finished: 4 errors, 0 warnings ===|

And this the code
Code
#include <boost/python.hpp>

#include <iostream>

using namespace std;
namespace python = boost::python;

int main(){

    Py_Initialize();

    python::object l;

    python::object main_module = python::import("__main__");
    python::object main_namespace = main_module.attr("__dict__");

    python::object ignored = python::exec("hello = file('hello.txt', 'w')\n"
                                          "hello.write('Hello world!')\n"
                                          "hello.close()",
                                          main_namespace);

    return 0;
}

Offline PJani

  • Single posting newcomer
  • *
  • Posts: 8
Re: [MinGW]libboost_python-mgw34-mt-d-1_39.lib is not being linked.
« Reply #3 on: July 04, 2009, 01:04:06 pm »
And this library was added by absolute path to codeblocks. Boost was build with mingw.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: [MinGW]libboost_python-mgw34-mt-d-1_39.lib is not being linked.
« Reply #4 on: July 05, 2009, 01:01:46 am »
And this library was added by absolute path to codeblocks. Boost was build with mingw.

Please turn on Full Compiler Logging per
http://wiki.codeblocks.org/index.php?title=FAQ#Q:_How_do_I_troubleshoot_an_compiler_problem.3F

And, post the Build Log to help me decide where error is.

Note: The Code::Blocks IDE does not always work well with absolute path to library.
It is better to put the path to Library in Linker search directory and the Library name in link library list.


But, this might be an Compiler Setup issue.
I am not sure how to set the Compiler up to use Boost Libraries.
And, http://wiki.codeblocks.org/index.php?title=BoostWindowsQuickRef does not do it the way I think is correct; but, I have never used Boost Libraries before.


Tim S

Note to Self:

Added following line to user-config.jam because my Python is in folder C:\Apps\Python26
Code
using python : 2.6 : C:\\Apps\\Python26 ;
« Last Edit: July 06, 2009, 01:56:22 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: [MinGW]libboost_python-mgw34-mt-d-1_39.lib is not being linked.
« Reply #5 on: July 05, 2009, 12:20:06 pm »
I got it to link with an absolute path to the boost_python-mgw34-mt-1_39.dll instead of .lib; but, it crashed on running the exe.

Note: Also, linked OK, if I renamed "boost_python-mgw34-mt.lib" to "libboost_python-mgw34-mt.a" and used that in the library name.

Tim S
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: [MinGW]libboost_python-mgw34-mt-d-1_39.lib is not being linked.
« Reply #6 on: July 05, 2009, 09:15:52 pm »
Made some test code that works OK for me.

Note: I am using MinGW GCC 4.4 DW2 for my testing; it gave error messages when it crashed; not, like MinGW 3.4.5.

Tim S

Code
#include <iostream>

#include <boost/python.hpp>

namespace python = boost::python;

int main(){

    Py_Initialize();

    python::object main_module = python::import("__main__");
    python::object global = main_module.attr("__dict__");

    python::object result = python::exec(
        "def greet():                   \n"
        "   return 'Hello from Python!' \n",
        global, global
    );

    // Create a reference to it.
    python::object greet = global["greet"];


    // Call it.
    std::string message = python::extract<std::string>(greet());
    std::cout << message << std::endl;

    return 0;
}

Snippet of my Build Log for you to compare with yours.

Note: I renamed "boost_python-mgw44-mt-1_39.lib" to "libboost_python-mgw44-mt-1_39.a" and used "boost_python-mgw44-mt-1_39" in the library name.

Code
mingw32-g++.exe -Wall -fexceptions  -O2   -fno-strict-aliasing   -IC:\Apps\Python26\include -IC:\GreenApps\MinGW_Boost\include\boost-1_39 -IC:\GreenApps\MinGW_Boost\include  -c C:\SourceCode\Projects\IDEs\CodeBlocks\Projects\BoostTest\main.cpp -o obj\Release\main.o
mingw32-g++.exe -LC:\Apps\Python26\libs -LC:\GreenApps\MinGW_Boost\lib  -o bin\Release\BoostTest.exe obj\Release\main.o   -s  -lpython26 -lboost_python-mgw44-mt-1_39
« Last Edit: July 05, 2009, 09:26:24 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline verysimplenick

  • Single posting newcomer
  • *
  • Posts: 4
Re: [MinGW]libboost_python-mgw34-mt-d-1_39.lib is not being linked.
« Reply #7 on: June 06, 2010, 10:47:10 am »
Can u told me how you build boost with python (maybe link to tutorial?)

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: [MinGW]libboost_python-mgw34-mt-d-1_39.lib is not being linked.
« Reply #8 on: June 06, 2010, 03:56:04 pm »
I used multiple sites for directions here some of them will add them as I find them.

http://www.boost.org/doc/libs/1_35_0/more/getting_started/windows.html


The two bjam commands from the batch file below; I found out by trial and error that mixing --with-XXX ans --without-XXX did not work.
IIRC I used --with-python or --without-mpi to build python; been to long for me to be sure.
Quote
    bjam -q      -d0 --with-graph --prefix="%_MINGWBASEFOLDER%" --build-dir=C:\temp\BoostTmp threading=multi variant=release link=shared toolset=gcc install
REM bjam -q      -d0 --without-mpi --prefix="%_MINGWBASEFOLDER%" --build-dir=C:\temp\BoostTmp threading=multi variant=debug   link=shared toolset=gcc install

Found my batch file I used to build boost

build-boost.bat
Code
SET _MINGWBASEFOLDER=C:\GreenApps\MinGW_Boost
SET PATH=%_MINGWBASEFOLDER%\bin;%PATH%

cd C:\SourceCode\Libraries\Boost\boost_1_39_0

REM SET EXPAT_INCLUDE=%_MINGWBASEFOLDER%
REM SET EXPAT_LIBPATH=%_MINGWBASEFOLDER%

REM
REM Change file user-config.jam by adding the line, without quotes,
REM "using python : 2.6 : C:\\Apps\\Python26 ;" to it.
REM


REM bjam option info
REM     -d+2 Show commands as they are executed
REM     -d0 Supress all informational messages
REM     -q Stop at first error
REM     --debug-configuration Diagnose configuration
REM bjam troubleshoot with "-q -d+2 --debug-configuration"
REM bjam normal build with "-q -d0"

REM
REM Clean
REM
REM bjam --clean -d0 --without-mpi --prefix="%_MINGWBASEFOLDER%" --build-dir=C:\temp\BoostTmp threading=multi variant=release link=shared toolset=gcc install
REM bjam --clean -d0 --without-mpi --prefix="%_MINGWBASEFOLDER%" --build-dir=C:\temp\BoostTmp threading=multi variant=debug   link=shared toolset=gcc install

REM PAUSE

REM
REM Build
REM
    bjam -q      -d0 --with-graph --prefix="%_MINGWBASEFOLDER%" --build-dir=C:\temp\BoostTmp threading=multi variant=release link=shared toolset=gcc install
REM bjam -q      -d0 --without-mpi --prefix="%_MINGWBASEFOLDER%" --build-dir=C:\temp\BoostTmp threading=multi variant=debug   link=shared toolset=gcc install

    PAUSE

    goto _end

CD %_MINGWBASEFOLDER%\lib

copy boost_date_time-mgw44-mt-1_39.lib                libboost_date_time-mgw44-mt-1_39.a
copy boost_date_time-mgw44-mt-d-1_39.lib              libboost_date_time-mgw44-mt-d-1_39.a
copy boost_date_time-mgw44-mt-d.lib                   libboost_date_time-mgw44-mt-d.a
copy boost_date_time-mgw44-mt.lib                     libboost_date_time-mgw44-mt.a
copy boost_filesystem-mgw44-mt-1_39.lib               libboost_filesystem-mgw44-mt-1_39.a
copy boost_filesystem-mgw44-mt-d-1_39.lib             libboost_filesystem-mgw44-mt-d-1_39.a
copy boost_filesystem-mgw44-mt-d.lib                  libboost_filesystem-mgw44-mt-d.a
copy boost_filesystem-mgw44-mt.lib                    libboost_filesystem-mgw44-mt.a
copy boost_graph-mgw44-mt-1_39.lib                    libboost_graph-mgw44-mt-1_39.a
copy boost_graph-mgw44-mt-d-1_39.lib                  libboost_graph-mgw44-mt-d-1_39.a
copy boost_graph-mgw44-mt-d.lib                       libboost_graph-mgw44-mt-d.a
copy boost_graph-mgw44-mt.lib                         libboost_graph-mgw44-mt.a
copy boost_iostreams-mgw44-mt-1_39.lib                libboost_iostreams-mgw44-mt-1_39.a
copy boost_iostreams-mgw44-mt-d-1_39.lib              libboost_iostreams-mgw44-mt-d-1_39.a
copy boost_iostreams-mgw44-mt-d.lib                   libboost_iostreams-mgw44-mt-d.a
copy boost_iostreams-mgw44-mt.lib                     libboost_iostreams-mgw44-mt.a
copy boost_math_c99-mgw44-mt-1_39.lib                 libboost_math_c99-mgw44-mt-1_39.a
copy boost_math_c99-mgw44-mt-d-1_39.lib               libboost_math_c99-mgw44-mt-d-1_39.a
copy boost_math_c99-mgw44-mt-d.lib                    libboost_math_c99-mgw44-mt-d.a
copy boost_math_c99-mgw44-mt.lib                      libboost_math_c99-mgw44-mt.a
copy boost_math_c99f-mgw44-mt-1_39.lib                libboost_math_c99f-mgw44-mt-1_39.a
copy boost_math_c99f-mgw44-mt-d-1_39.lib              libboost_math_c99f-mgw44-mt-d-1_39.a
copy boost_math_c99f-mgw44-mt-d.lib                   libboost_math_c99f-mgw44-mt-d.a
copy boost_math_c99f-mgw44-mt.lib                     libboost_math_c99f-mgw44-mt.a
copy boost_math_c99l-mgw44-mt-1_39.lib                libboost_math_c99l-mgw44-mt-1_39.a
copy boost_math_c99l-mgw44-mt-d-1_39.lib              libboost_math_c99l-mgw44-mt-d-1_39.a
copy boost_math_c99l-mgw44-mt-d.lib                   libboost_math_c99l-mgw44-mt-d.a
copy boost_math_c99l-mgw44-mt.lib                     libboost_math_c99l-mgw44-mt.a
copy boost_math_tr1-mgw44-mt-1_39.lib                 libboost_math_tr1-mgw44-mt-1_39.a
copy boost_math_tr1-mgw44-mt-d-1_39.lib               libboost_math_tr1-mgw44-mt-d-1_39.a
copy boost_math_tr1-mgw44-mt-d.lib                    libboost_math_tr1-mgw44-mt-d.a
copy boost_math_tr1-mgw44-mt.lib                      libboost_math_tr1-mgw44-mt.a
copy boost_math_tr1f-mgw44-mt-1_39.lib                libboost_math_tr1f-mgw44-mt-1_39.a
copy boost_math_tr1f-mgw44-mt-d-1_39.lib              libboost_math_tr1f-mgw44-mt-d-1_39.a
copy boost_math_tr1f-mgw44-mt-d.lib                   libboost_math_tr1f-mgw44-mt-d.a
copy boost_math_tr1f-mgw44-mt.lib                     libboost_math_tr1f-mgw44-mt.a
copy boost_math_tr1l-mgw44-mt-1_39.lib                libboost_math_tr1l-mgw44-mt-1_39.a
copy boost_math_tr1l-mgw44-mt-d-1_39.lib              libboost_math_tr1l-mgw44-mt-d-1_39.a
copy boost_math_tr1l-mgw44-mt-d.lib                   libboost_math_tr1l-mgw44-mt-d.a
copy boost_math_tr1l-mgw44-mt.lib                     libboost_math_tr1l-mgw44-mt.a
copy boost_prg_exec_monitor-mgw44-mt-1_39.lib         libboost_prg_exec_monitor-mgw44-mt-1_39.a
copy boost_prg_exec_monitor-mgw44-mt-d-1_39.lib       libboost_prg_exec_monitor-mgw44-mt-d-1_39.a
copy boost_prg_exec_monitor-mgw44-mt-d.lib            libboost_prg_exec_monitor-mgw44-mt-d.a
copy boost_prg_exec_monitor-mgw44-mt.lib              libboost_prg_exec_monitor-mgw44-mt.a
copy boost_program_options-mgw44-mt-1_39.lib          libboost_program_options-mgw44-mt-1_39.a
copy boost_program_options-mgw44-mt-d-1_39.lib        libboost_program_options-mgw44-mt-d-1_39.a
copy boost_program_options-mgw44-mt-d.lib             libboost_program_options-mgw44-mt-d.a
copy boost_program_options-mgw44-mt.lib               libboost_program_options-mgw44-mt.a
copy boost_python-mgw44-mt-1_39.lib                   libboost_python-mgw44-mt-1_39.a
copy boost_python-mgw44-mt-d-1_39.lib                 libboost_python-mgw44-mt-d-1_39.a
copy boost_python-mgw44-mt-d.lib                      libboost_python-mgw44-mt-d.a
copy boost_python-mgw44-mt.lib                        libboost_python-mgw44-mt.a
copy boost_serialization-mgw44-mt-1_39.lib            libboost_serialization-mgw44-mt-1_39.a
copy boost_serialization-mgw44-mt-d-1_39.lib          libboost_serialization-mgw44-mt-d-1_39.a
copy boost_serialization-mgw44-mt-d.lib               libboost_serialization-mgw44-mt-d.a
copy boost_serialization-mgw44-mt.lib                 libboost_serialization-mgw44-mt.a
copy boost_signals-mgw44-mt-1_39.lib                  libboost_signals-mgw44-mt-1_39.a
copy boost_signals-mgw44-mt-d-1_39.lib                libboost_signals-mgw44-mt-d-1_39.a
copy boost_signals-mgw44-mt-d.lib                     libboost_signals-mgw44-mt-d.a
copy boost_signals-mgw44-mt.lib                       libboost_signals-mgw44-mt.a
copy boost_system-mgw44-mt-1_39.lib                   libboost_system-mgw44-mt-1_39.a
copy boost_system-mgw44-mt-d-1_39.lib                 libboost_system-mgw44-mt-d-1_39.a
copy boost_system-mgw44-mt-d.lib                      libboost_system-mgw44-mt-d.a
copy boost_system-mgw44-mt.lib                        libboost_system-mgw44-mt.a
copy boost_thread-mgw44-mt-1_39.lib                   libboost_thread-mgw44-mt-1_39.a
copy boost_thread-mgw44-mt-d-1_39.lib                 libboost_thread-mgw44-mt-d-1_39.a
copy boost_thread-mgw44-mt-d.lib                      libboost_thread-mgw44-mt-d.a
copy boost_thread-mgw44-mt.lib                        libboost_thread-mgw44-mt.a
copy boost_unit_test_framework-mgw44-mt-1_39.lib      libboost_unit_test_framework-mgw44-mt-1_39.a
copy boost_unit_test_framework-mgw44-mt-d-1_39.lib    libboost_unit_test_framework-mgw44-mt-d-1_39.a
copy boost_unit_test_framework-mgw44-mt-d.lib         libboost_unit_test_framework-mgw44-mt-d.a
copy boost_unit_test_framework-mgw44-mt.lib           libboost_unit_test_framework-mgw44-mt.a
copy boost_wave-mgw44-mt-1_39.lib                     libboost_wave-mgw44-mt-1_39.a
copy boost_wave-mgw44-mt-d-1_39.lib                   libboost_wave-mgw44-mt-d-1_39.a
copy boost_wave-mgw44-mt-d.lib                        libboost_wave-mgw44-mt-d.a
copy boost_wave-mgw44-mt.lib                          libboost_wave-mgw44-mt.a
copy boost_wserialization-mgw44-mt-1_39.lib           libboost_wserialization-mgw44-mt-1_39.a
copy boost_wserialization-mgw44-mt-d-1_39.lib         libboost_wserialization-mgw44-mt-d-1_39.a
copy boost_wserialization-mgw44-mt-d.lib              libboost_wserialization-mgw44-mt-d.a
copy boost_wserialization-mgw44-mt.lib                libboost_wserialization-mgw44-mt.a
copy libboost_regex-mgw44-mt-1_39.lib                 libboost_regex-mgw44-mt-1_39.a
copy libboost_regex-mgw44-mt-d-1_39.lib               libboost_regex-mgw44-mt-d-1_39.a
copy libboost_regex-mgw44-mt-d.lib                    libboost_regex-mgw44-mt-d.a
copy libboost_regex-mgw44-mt.lib                      libboost_regex-mgw44-mt.a
copy libboost_test_exec_monitor-mgw44-mt-1_39.lib     libboost_test_exec_monitor-mgw44-mt-1_39.a
copy libboost_test_exec_monitor-mgw44-mt-d-1_39.lib   libboost_test_exec_monitor-mgw44-mt-d-1_39.a
copy libboost_test_exec_monitor-mgw44-mt-d.lib        libboost_test_exec_monitor-mgw44-mt-d.a
copy libboost_test_exec_monitor-mgw44-mt.lib          libboost_test_exec_monitor-mgw44-mt.a


:_end
    PAUSE



Tim S.
« Last Edit: June 06, 2010, 04:19:29 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline verysimplenick

  • Single posting newcomer
  • *
  • Posts: 4
Re: [MinGW]libboost_python-mgw34-mt-d-1_39.lib is not being linked.
« Reply #9 on: June 07, 2010, 03:06:14 pm »
"--without-mpi" really help,thx Tim.
I used "--with-python" but boost::python not build in gcc,althought toolset=vc build it right(something wrong with config gcc?!)