LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Problems with boost (https://www.linuxquestions.org/questions/programming-9/problems-with-boost-379591/)

nathacof 11-03-2005 09:55 AM

Problems with boost
 
BTW this post is about a windows computer, but since I'm using primarily open source tools I figured what the hay.

OK so far I've run bjam -sTOOLS=mingw install which dumped a bunch of directories with header files into C:\boost\include\boost-1_33

I then tried this sample code http://www.boost.org/libs/filesystem.../simple_ls.cpp
(I've tried editing the #include line to suit my setup but to no avail)

No luck compiler spits out file not found errors anywhere I try to use boost.

In Dev-C++ I've edited the compiler options to include C:\boost\include (I moved all the directories from boost-1_33 to C:\boost\include, I didn't think this would be a problem) but I noticed the lib directory was empty (not sure if this matters) so I ran bjam -sTOOLS=mingw stage and dumped the library files into C:\boost\lib, also updated Dev-C++'s settings to search this directory for lib files.

Still the program won't compile. Same error every time. I even tried specifying the include path on the command line using g++.

Any help would be greatly appreciated.

Thanks.

YetAnotherDave 11-03-2005 10:32 AM

Is it important to you to use Dev-C++ ? I've been using cygwin/boost/mingw/g++ on the command line in windows with no problems. The sample program compiled fine for me. I can give you more info but I don't want to waste my time ( and yours ) if this is a solution that does not work for you.

- Dave

nathacof 11-03-2005 12:20 PM

I have tried using g++ on the command line.
Code:

g++ simple_ls.cpp -o ls -IC:\boost\include -LC:\boost\lib -lboost
still I'm getting the same compiler error.

YetAnotherDave 11-03-2005 01:16 PM

Here's what works for me ( clean compile & link ):


Code:

g++ simple_ls.cpp -o ls  -Ic:\Boost\include\boost-1_33  -Lc:\Boost\lib -lboost_filesystem-gcc
This may not make any difference but when I installed boost, I used:

Code:

bjam "-sTOOLS=gcc" install
rather than:

Code:

bjam "-sTOOLS=mingw" install

nathacof 11-04-2005 10:50 AM

OK I've done the install using -sTOOLS=gcc everything worked out pretty much the same. All the files are in c:\Boost\include\boost-1_33 using the same command as you've supplied I tried compiling from the command line with still the same results.

Can anyone tell me why this might be happening? I'm using boost supplied source code, and it compiles for everyone else... so this is kind of weird.

Perhaps it's because the directory I'm compiling from is in My Documents <- which contains a space in the name. I'll try from a new dir and get back to you guys.

nathacof 11-04-2005 10:57 AM

OK this is the result of the compile after moving the source code to C:\src
Code:

C:\src>g++ simple_ls.cpp -o ls -LC:\boost\lib\boost-1_33 -IC:\boost\include\boos
t-1_33 -lboost_filesystem-gcc
C:\Dev-Cpp\bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\mingw32\bin\ld.exe: cannot f
ind -lboost_filesystem-gcc
collect2: ld returned 1 exit status

C:\src>

So this is an obvious improvement. Still I am unsure as to the usage of the -l arguement. If I leave it out I get a hole slew of errors. Hopefully I can figure this out.

Any help is appreciated.

YetAnotherDave 11-04-2005 11:45 AM

Your -L argument is wrong. Use:

Code:

g++ simple_ls.cpp -o ls -LC:\boost\lib -IC:\boost\include\boost-1_33 -lboost_filesystem-gcc

nathacof 11-04-2005 12:04 PM

sheesh that worked. But now windows is complaining about missing boost_filesystem-gcc-1_33.dll. What's up with that?

YetAnotherDave 11-04-2005 12:29 PM

That's because the executable does not know where to find the dll. There are a few ways to fix this but probably the best way is to tell it where to look for the dll by modifying your Path variable as follows:

set Path=c:\Boost\lib;%Path%

There are ways to make this happen automatically for a new command window but I don't remember how offhand.

- Dave

nathacof 11-04-2005 12:36 PM

Thanks for the help. I got it working! I copied the neccessary dll into the src directory. That works for now. I need to look into staticlly compiling but that's for another day.

Thanks again!

YetAnotherDave 11-04-2005 12:56 PM

Glad to hear you got it working!

Yes, copying the dll will work but it's not a very maintainable solution because you have to copy every boost shared library used by an executable to the folder of the executable. Not only that but you have to do this for every different folder at which you have created executables that use boost.

Static linking will also work but will result in larger executables that link slower. On the other hand it generates executables that are more self-contained and depend on a simpler run-time environment.

Of course, what works best for you depends on your circumstances.

- Dave


All times are GMT -5. The time now is 01:54 AM.