Jump to content
  • Advertisement
Sign in to follow this  
Storyyeller

how do I build a library?

This topic is 3091 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've never been able to figure this out. Today, I decided to try using the Boost libraries. Since it has an unusually detailed tutorial, I thought I might be able to actually do this one. Step 1: It looks like the only precompiled binaries available are for Visual Studio. Since I am using Code::Blocks (my os is Windows Vista), I guess I need to build the libraries myself. Step 2: Apparently I need some program called bjam. It says that there are precompiled binary version of bjam available, but I tried downloading a file from the link provided, and it had no binaries as far as I can tell. Step 3: So I attempted to build bjam. I got as far as using the command prompt to go to the directory C:\boost_1_38_0\tools\jam\src and then run build.bat Unfortunately, it said 'cl' is not recognized as a command I figured that it was picking the wrong toolset or something, so I tried .\build.bat mingw and .\build.bat gcc, but both of these resulted in the message that 'gcc' is not a recognized command. So what I do I do next? I'm guessing that I need to get gcc and place it in some special directory, but I am not sure where to put it. Do I need to copy it into the jam source folder? That seems a little weird. What am I doing wrong? How do you learn to build libraries?

Share this post


Link to post
Share on other sites
Advertisement
You only need to build boost for certain libraries so if you want to start experimenting with boost while you figure out how to build the non-header-only parts of the boost library you can do so.

As for bjam, did you not see a version for windows here? There will be a folder called boost-jam and then subfolders for different bjam versions. In the latest version (at this time), 3.1.17, there are 6 files you can try, but you can rule out 3 of them immediately (linuxx86, macosx86, and freebsdx86 are obviously not any form of Windows). Also, on the Windows platform, if you have a choice between .tgz and .zip you will generally want to choose .zip. That leaves 2 files. I tried the ntx86 because I figured "NT" probably meant "NT based platforms" especially since the other platforms followed the same format as this file. This contained an executable and readme. I then checked the plain .zip file just to see what was in it and found a large amount of source code and other misc. files, but no windows .exe file.

Hope this helps.

Share this post


Link to post
Share on other sites
And FYI, cl.exe is the compiler for Visual C++ so whatever it is you were doing was assuming you had Visual C++. You don't need to get gcc as that is essentially what you are using with Code::Blocks. Code::Blocks comes with a port of gcc for windows known as MinGW. That is what you have been compiling with when using Code::Blocks. Also, to the best of my knowledge, MinGW lags far behind the latest version of gcc. I could be mistaken, I haven't used MinGW in awhile.

Share this post


Link to post
Share on other sites
Quote:
Original post by nobodynews
You only need to build boost for certain libraries so if you want to start experimenting with boost while you figure out how to build the non-header-only parts of the boost library you can do so.


I wanted to use the Filesystem library.


Quote:
Original post by nobodynews
As for bjam, did you not see a version for windows here? There will be a folder called boost-jam and then subfolders for different bjam versions. In the latest version (at this time), 3.1.17, there are 6 files you can try, but you can rule out 3 of them immediately (linuxx86, macosx86, and freebsdx86 are obviously not any form of Windows). Also, on the Windows platform, if you have a choice between .tgz and .zip you will generally want to choose .zip. That leaves 2 files. I tried the ntx86 because I figured "NT" probably meant "NT based platforms" especially since the other platforms followed the same format as this file. This contained an executable and readme. I then checked the plain .zip file just to see what was in it and found a large amount of source code and other misc. files, but no windows .exe file.

Hope this helps.

I downloaded the other zip. (The one without the exe). I'll try the nt one now.

Ok, so I have bjam now, but I can't figure out how to do the rest.
I keep getting an error about rule path.make( native ) called with ()

Share this post


Link to post
Share on other sites
I still haven't been able to get it working

I tried copying gcc and g++ into the same directory as bjam

Here are the messages I got

C:\boost_1_38_0>bjam ^
More? --with-filesystem ^
More? toolset=gcc
...patience...
...found 437 targets...
...updating 29 targets...
common.mkdir bin.v2
common.mkdir bin.v2\libs
common.mkdir bin.v2\libs\filesystem
common.mkdir bin.v2\libs\filesystem\build
common.mkdir bin.v2\libs\filesystem\build\gcc-mingw-3.4.5
common.mkdir bin.v2\libs\filesystem\build\gcc-mingw-3.4.5\release
common.mkdir bin.v2\libs\filesystem\build\gcc-mingw-3.4.5\release\threading-mult
i
gcc.compile.c++ bin.v2\libs\filesystem\build\gcc-mingw-3.4.5\release\threading-m
ulti\operations.o
g++: installation problem, cannot exec `cc1plus': No such file or directory

"g++" -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -mthrea
ds -DBOOST_ALL_DYN_LINK=1 -DBOOST_ALL_NO_LIB=1 -DBOOST_SYSTEM_DYN_LINK=1 -DNDEB
UG -I"." -c -o "bin.v2\libs\filesystem\build\gcc-mingw-3.4.5\release\threading-
multi\operations.o" "libs\filesystem\src\operations.cpp"

...failed gcc.compile.c++ bin.v2\libs\filesystem\build\gcc-mingw-3.4.5\release\t
hreading-multi\operations.o...
gcc.compile.c++ bin.v2\libs\filesystem\build\gcc-mingw-3.4.5\release\threading-m
ulti\path.o
g++: installation problem, cannot exec `cc1plus': No such file or directory

"g++" -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -mthrea
ds -DBOOST_ALL_DYN_LINK=1 -DBOOST_ALL_NO_LIB=1 -DBOOST_SYSTEM_DYN_LINK=1 -DNDEB
UG -I"." -c -o "bin.v2\libs\filesystem\build\gcc-mingw-3.4.5\release\threading-
multi\path.o" "libs\filesystem\src\path.cpp"

...failed gcc.compile.c++ bin.v2\libs\filesystem\build\gcc-mingw-3.4.5\release\t
hreading-multi\path.o...
gcc.compile.c++ bin.v2\libs\filesystem\build\gcc-mingw-3.4.5\release\threading-m
ulti\portability.o
g++: installation problem, cannot exec `cc1plus': No such file or directory

"g++" -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -mthrea
ds -DBOOST_ALL_DYN_LINK=1 -DBOOST_ALL_NO_LIB=1 -DBOOST_SYSTEM_DYN_LINK=1 -DNDEB
UG -I"." -c -o "bin.v2\libs\filesystem\build\gcc-mingw-3.4.5\release\threading-
multi\portability.o" "libs\filesystem\src\portability.cpp"

...failed gcc.compile.c++ bin.v2\libs\filesystem\build\gcc-mingw-3.4.5\release\t
hreading-multi\portability.o...
gcc.compile.c++ bin.v2\libs\filesystem\build\gcc-mingw-3.4.5\release\threading-m
ulti\utf8_codecvt_facet.o
g++: installation problem, cannot exec `cc1plus': No such file or directory

"g++" -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -mthrea
ds -DBOOST_ALL_DYN_LINK=1 -DBOOST_ALL_NO_LIB=1 -DBOOST_SYSTEM_DYN_LINK=1 -DNDEB
UG -I"." -c -o "bin.v2\libs\filesystem\build\gcc-mingw-3.4.5\release\threading-
multi\utf8_codecvt_facet.o" "libs\filesystem\src\utf8_codecvt_facet.cpp"

...failed gcc.compile.c++ bin.v2\libs\filesystem\build\gcc-mingw-3.4.5\release\t
hreading-multi\utf8_codecvt_facet.o...
common.mkdir bin.v2\libs\system
common.mkdir bin.v2\libs\system\build
common.mkdir bin.v2\libs\system\build\gcc-mingw-3.4.5
common.mkdir bin.v2\libs\system\build\gcc-mingw-3.4.5\release
common.mkdir bin.v2\libs\system\build\gcc-mingw-3.4.5\release\threading-multi
gcc.compile.c++ bin.v2\libs\system\build\gcc-mingw-3.4.5\release\threading-multi
\error_code.o
g++: installation problem, cannot exec `cc1plus': No such file or directory

"g++" -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -mthrea
ds -DBOOST_ALL_NO_LIB=1 -DBOOST_SYSTEM_DYN_LINK=1 -DNDEBUG -I"." -c -o "bin.v2
\libs\system\build\gcc-mingw-3.4.5\release\threading-multi\error_code.o" "libs\s
ystem\src\error_code.cpp"

...failed gcc.compile.c++ bin.v2\libs\system\build\gcc-mingw-3.4.5\release\threa
ding-multi\error_code.o...
...skipped <pbin.v2\libs\system\build\gcc-mingw-3.4.5\release\threading-multi>bo
ost_system-mgw34-mt-1_38.lib for lack of <pbin.v2\libs\system\build\gcc-mingw-3.
4.5\release\threading-multi>error_code.o...
...skipped <pbin.v2\libs\system\build\gcc-mingw-3.4.5\release\threading-multi>bo
ost_system-mgw34-mt-1_38.dll for lack of <pbin.v2\libs\system\build\gcc-mingw-3.
4.5\release\threading-multi>error_code.o...
...skipped <pbin.v2\libs\filesystem\build\gcc-mingw-3.4.5\release\threading-mult
i>boost_filesystem-mgw34-mt-1_38.lib for lack of <pbin.v2\libs\filesystem\buildgcc-mingw-3.4.5\release\threading-multi>operations.o...
...skipped <pbin.v2\libs\filesystem\build\gcc-mingw-3.4.5\release\threading-mult
i>boost_filesystem-mgw34-mt-1_38.dll for lack of <pbin.v2\libs\filesystem\buildgcc-mingw-3.4.5\release\threading-multi>operations.o...
common.mkdir bin.v2\libs\filesystem\build\gcc-mingw-3.4.5\release\link-static
common.mkdir bin.v2\libs\filesystem\build\gcc-mingw-3.4.5\release\link-static\th
reading-multi
gcc.compile.c++ bin.v2\libs\filesystem\build\gcc-mingw-3.4.5\release\link-static
\threading-multi\operations.o
g++: installation problem, cannot exec `cc1plus': No such file or directory

"g++" -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -mthrea
ds -DBOOST_ALL_NO_LIB=1 -DBOOST_All_STATIC_LINK=1 -DBOOST_SYSTEM_STATIC_LINK=1
-DNDEBUG -I"." -c -o "bin.v2\libs\filesystem\build\gcc-mingw-3.4.5\release\link
-static\threading-multi\operations.o" "libs\filesystem\src\operations.cpp"

...failed gcc.compile.c++ bin.v2\libs\filesystem\build\gcc-mingw-3.4.5\release\l
ink-static\threading-multi\operations.o...
gcc.compile.c++ bin.v2\libs\filesystem\build\gcc-mingw-3.4.5\release\link-static
\threading-multi\path.o
g++: installation problem, cannot exec `cc1plus': No such file or directory

"g++" -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -mthrea
ds -DBOOST_ALL_NO_LIB=1 -DBOOST_All_STATIC_LINK=1 -DBOOST_SYSTEM_STATIC_LINK=1
-DNDEBUG -I"." -c -o "bin.v2\libs\filesystem\build\gcc-mingw-3.4.5\release\link
-static\threading-multi\path.o" "libs\filesystem\src\path.cpp"

...failed gcc.compile.c++ bin.v2\libs\filesystem\build\gcc-mingw-3.4.5\release\l
ink-static\threading-multi\path.o...
gcc.compile.c++ bin.v2\libs\filesystem\build\gcc-mingw-3.4.5\release\link-static
\threading-multi\portability.o
g++: installation problem, cannot exec `cc1plus': No such file or directory

"g++" -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -mthrea
ds -DBOOST_ALL_NO_LIB=1 -DBOOST_All_STATIC_LINK=1 -DBOOST_SYSTEM_STATIC_LINK=1
-DNDEBUG -I"." -c -o "bin.v2\libs\filesystem\build\gcc-mingw-3.4.5\release\link
-static\threading-multi\portability.o" "libs\filesystem\src\portability.cpp"

...failed gcc.compile.c++ bin.v2\libs\filesystem\build\gcc-mingw-3.4.5\release\l
ink-static\threading-multi\portability.o...
gcc.compile.c++ bin.v2\libs\filesystem\build\gcc-mingw-3.4.5\release\link-static
\threading-multi\utf8_codecvt_facet.o
g++: installation problem, cannot exec `cc1plus': No such file or directory

"g++" -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -mthrea
ds -DBOOST_ALL_NO_LIB=1 -DBOOST_All_STATIC_LINK=1 -DBOOST_SYSTEM_STATIC_LINK=1
-DNDEBUG -I"." -c -o "bin.v2\libs\filesystem\build\gcc-mingw-3.4.5\release\link
-static\threading-multi\utf8_codecvt_facet.o" "libs\filesystem\src\utf8_codecvt_
facet.cpp"

...failed gcc.compile.c++ bin.v2\libs\filesystem\build\gcc-mingw-3.4.5\release\l
ink-static\threading-multi\utf8_codecvt_facet.o...
...skipped <pbin.v2\libs\filesystem\build\gcc-mingw-3.4.5\release\link-static\th
reading-multi>libboost_filesystem-mgw34-mt-1_38.lib(clean) for lack of <pbin.v2libs\filesystem\build\gcc-mingw-3.4.5\release\link-static\threading-multi>operat
ions.o...
...skipped <pbin.v2\libs\filesystem\build\gcc-mingw-3.4.5\release\link-static\th
reading-multi>libboost_filesystem-mgw34-mt-1_38.lib for lack of <pbin.v2\libs\fi
lesystem\build\gcc-mingw-3.4.5\release\link-static\threading-multi>operations.o.
..
...failed updating 9 targets...
...skipped 6 targets...
...updated 14 targets...

C:\boost_1_38_0>




-Edited to place messages in a source box do to extreme length

[Edited by - Storyyeller on December 3, 2009 9:26:31 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by Storyyeller
I still haven't been able to get it working

I tried copying gcc and g++ into the same directory as bjam


Just put the binary directory of gcc (that where gcc.exe, g++.exe, cc1plus.exe etc. are located) into your %PATH% variable. You might also need to adjust other environment variables for GCC to find its headers/libs/etc.

Share this post


Link to post
Share on other sites
Which part? Updating the environment variables in general or updating it specifically for "other environment variables for GCC to find its headers/libs/etc.
"? I'm on an XP machine so the steps to do this might be different on Vista. Go to the control panel and find "System". Open it and look at the "Advanced" tab. Find the variable named path, select it, then click "edit". Add the location of MinGW/bin directory to the paths already listed, seperating them with a semi-colon(;). I don't know about what you'd do to get the paths set up for the headers library files. Sorry.

Share this post


Link to post
Share on other sites
Ok, I managed to get it built.
Now I just need to figure out how to use the options to get the correct version built and how to link it to my program.

I ended up with the files
boost_filesystem-mgw34-mt-1_38.dll
boost_filesystem-mgw34-mt-1_38.lib
operations.o
path.o
portaility.o
utf8_codecvt_facet.o

in the folder C:\btest\boost\bin.v2\libs\filesystem\build\gcc-mingw-3.4.5\release\threading-multi

What are the object files for?
I tried linking to boost_filesystem-mgw34-mt-1_38.lib, and including filesystem.hpp but it turns up with a lot of errors in error_code.hpp
undefined reference to `boost::system::get_system_category()
undefined reference to `boost::system::get_generic_category()
undefined reference to `boost::system::get_generic_category()
etc.

Is trying to link a release version of the library from a debug build in Code::Blocks a bad idea? Do I need to build separate debug versions of the boost libraries?
Or is there something else I'm doing wrong?

Share this post


Link to post
Share on other sites
Quote:
Original post by Storyyeller
Ok, I managed to get it built.
Now I just need to figure out how to use the options to get the correct version built and how to link it to my program.

I ended up with the files
boost_filesystem-mgw34-mt-1_38.dll
boost_filesystem-mgw34-mt-1_38.lib
operations.o
path.o
portaility.o
utf8_codecvt_facet.o

in the folder C:\btest\boost\bin.v2\libs\filesystem\build\gcc-mingw-3.4.5\release\threading-multi

What are the object files for?
I tried linking to boost_filesystem-mgw34-mt-1_38.lib, and including filesystem.hpp but it turns up with a lot of errors in error_code.hpp
undefined reference to `boost::system::get_system_category()
undefined reference to `boost::system::get_generic_category()
undefined reference to `boost::system::get_generic_category()
etc.

Is trying to link a release version of the library from a debug build in Code::Blocks a bad idea? Do I need to build separate debug versions of the boost libraries?
Or is there something else I'm doing wrong?


The .o (object) files is the compiled versions of the source files. The lib/dll files is basically a collection archive containing these object files, and is all you will need.

I suspect that all you need to do now is to make sure the dll file is found when CodeBlocks tries to link them into your program. You can do this by adding the directory where the dll file is to the PATH variable.

Another option is to tell CodeBlocks where it can find binaries. I'm not sure how to do this using CodeBlocks so you'll just have to look around in the settings

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!