Public Group

# how do I build a library?

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

## 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 on other sites
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 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 on other sites
Quote:
 Original post by nobodynewsYou 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 nobodynewsAs 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 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.v2common.mkdir bin.v2\libscommon.mkdir bin.v2\libs\filesystemcommon.mkdir bin.v2\libs\filesystem\buildcommon.mkdir bin.v2\libs\filesystem\build\gcc-mingw-3.4.5common.mkdir bin.v2\libs\filesystem\build\gcc-mingw-3.4.5\releasecommon.mkdir bin.v2\libs\filesystem\build\gcc-mingw-3.4.5\release\threading-multigcc.compile.c++ bin.v2\libs\filesystem\build\gcc-mingw-3.4.5\release\threading-multi\operations.og++: installation problem, cannot exec cc1plus': No such file or directory    "g++"  -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -mthreads  -DBOOST_ALL_DYN_LINK=1 -DBOOST_ALL_NO_LIB=1 -DBOOST_SYSTEM_DYN_LINK=1 -DNDEBUG  -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\threading-multi\operations.o...gcc.compile.c++ bin.v2\libs\filesystem\build\gcc-mingw-3.4.5\release\threading-multi\path.og++: installation problem, cannot exec cc1plus': No such file or directory    "g++"  -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -mthreads  -DBOOST_ALL_DYN_LINK=1 -DBOOST_ALL_NO_LIB=1 -DBOOST_SYSTEM_DYN_LINK=1 -DNDEBUG  -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\threading-multi\path.o...gcc.compile.c++ bin.v2\libs\filesystem\build\gcc-mingw-3.4.5\release\threading-multi\portability.og++: installation problem, cannot exec cc1plus': No such file or directory    "g++"  -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -mthreads  -DBOOST_ALL_DYN_LINK=1 -DBOOST_ALL_NO_LIB=1 -DBOOST_SYSTEM_DYN_LINK=1 -DNDEBUG  -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\threading-multi\portability.o...gcc.compile.c++ bin.v2\libs\filesystem\build\gcc-mingw-3.4.5\release\threading-multi\utf8_codecvt_facet.og++: installation problem, cannot exec cc1plus': No such file or directory    "g++"  -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -mthreads  -DBOOST_ALL_DYN_LINK=1 -DBOOST_ALL_NO_LIB=1 -DBOOST_SYSTEM_DYN_LINK=1 -DNDEBUG  -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\threading-multi\utf8_codecvt_facet.o...common.mkdir bin.v2\libs\systemcommon.mkdir bin.v2\libs\system\buildcommon.mkdir bin.v2\libs\system\build\gcc-mingw-3.4.5common.mkdir bin.v2\libs\system\build\gcc-mingw-3.4.5\releasecommon.mkdir bin.v2\libs\system\build\gcc-mingw-3.4.5\release\threading-multigcc.compile.c++ bin.v2\libs\system\build\gcc-mingw-3.4.5\release\threading-multi\error_code.og++: installation problem, cannot exec cc1plus': No such file or directory    "g++"  -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -mthreads  -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\system\src\error_code.cpp"...failed gcc.compile.c++ bin.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>boost_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>boost_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-multi>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-multi>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-staticcommon.mkdir bin.v2\libs\filesystem\build\gcc-mingw-3.4.5\release\link-static\threading-multigcc.compile.c++ bin.v2\libs\filesystem\build\gcc-mingw-3.4.5\release\link-static\threading-multi\operations.og++: installation problem, cannot exec cc1plus': No such file or directory    "g++"  -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -mthreads  -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\link-static\threading-multi\operations.o...gcc.compile.c++ bin.v2\libs\filesystem\build\gcc-mingw-3.4.5\release\link-static\threading-multi\path.og++: installation problem, cannot exec cc1plus': No such file or directory    "g++"  -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -mthreads  -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\link-static\threading-multi\path.o...gcc.compile.c++ bin.v2\libs\filesystem\build\gcc-mingw-3.4.5\release\link-static\threading-multi\portability.og++: installation problem, cannot exec cc1plus': No such file or directory    "g++"  -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -mthreads  -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\link-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.og++: installation problem, cannot exec cc1plus': No such file or directory    "g++"  -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -mthreads  -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\link-static\threading-multi\utf8_codecvt_facet.o......skipped <pbin.v2\libs\filesystem\build\gcc-mingw-3.4.5\release\link-static\threading-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>operations.o......skipped <pbin.v2\libs\filesystem\build\gcc-mingw-3.4.5\release\link-static\threading-multi>libboost_filesystem-mgw34-mt-1_38.lib for lack of <pbin.v2\libs\filesystem\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 on other sites
Quote:
 Original post by StoryyellerI still haven't been able to get it workingI 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 on other sites
How do I do that?

##### 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 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

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 on other sites
Quote:
 Original post by StoryyellerOk, 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 filesboost_filesystem-mgw34-mt-1_38.dllboost_filesystem-mgw34-mt-1_38.liboperations.opath.oportaility.outf8_codecvt_facet.oin the folder C:\btest\boost\bin.v2\libs\filesystem\build\gcc-mingw-3.4.5\release\threading-multiWhat 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.hppundefined 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

1. 1
Rutin
32
2. 2
3. 3
4. 4
5. 5

• 13
• 9
• 9
• 9
• 14
• ### Forum Statistics

• Total Topics
633317
• Total Posts
3011336
• ### Who's Online (See full list)

There are no registered users currently online

×