473,402 Members | 2,050 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

linker error building code with boost filesystem

3
Hello:
I am having trouble linking a couple of files using the boost::filesystem.
I am using MSVC 6.0.
Here is an abbreviated version of my problem:

foo.h:
Expand|Select|Wrap|Line Numbers
  1. #ifndef __FOO_ 
  2. #define __FOO_ 
  3. #include "boost/filesystem.hpp" 
  4. class foo 
  5. public 
  6. /*stuff*/ 
  7. private 
  8. boost::filesystem::path m_path; 
  9. }; 
  10. #endif 
  11.  
bar.h:
Expand|Select|Wrap|Line Numbers
  1. #ifndef __BAR_ 
  2. #define __BAR_ 
  3. class foo; 
  4. class bar 
  5. public 
  6. /*stuff*/ 
  7. private 
  8. foo* m_fooPtr; 
  9. }; 
  10. #endif 
  11.  
bar.cpp:
Expand|Select|Wrap|Line Numbers
  1. #include "foo.h" 
  2. /*use foo a lot*/ 
  3.  
  4.  
Here is the build result:

bar.obj : error LNK2005: "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl boost::filesystem::extension(class boost::filesystem::basic_path<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct boost::filesystem::path_traits> const &)" (?extension@filesystem@boost@@YA?AV?$basic_string@ DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV? $basic_path@V?$basic_string@DU?$char_traits@D@std@ @V?$allocator@D@2@@std@@Upath_traits@filesystem@bo ost@@@12@@Z) already defined in foo.obj
bar.obj : error LNK2005: "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl boost::filesystem::basename(class boost::filesystem::basic_path<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct boost::filesystem::path_traits> const &)" (?basename@filesystem@boost@@YA?AV?$basic_string@D U?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV?$ basic_path@V?$basic_string@DU?$char_traits@D@std@@ V?$allocator@D@2@@std@@Upath_traits@filesystem@boo st@@@12@@Z) already defined in foo.obj
Debug/FooBar.exe : fatal error LNK1169: one or more multiply defined symbols found

Any ideas on what the problem is?
Thanks
May 25 '07 #1
5 3405
weaknessforcats
9,208 Expert Mod 8TB
You need to #include <string>.
May 25 '07 #2
GaryE
3
Thanks, but that still doesn't work.
May 25 '07 #3
weaknessforcats
9,208 Expert Mod 8TB
And you have:

Expand|Select|Wrap|Line Numbers
  1. using namespace std;
  2.  
Yes?
May 27 '07 #4
GaryE
3
Yes. This makes no difference.
May 31 '07 #5
weaknessforcats
9,208 Expert Mod 8TB
This code:
Expand|Select|Wrap|Line Numbers
  1. boost::filesystem::path m_path; 
  2.  
requires a class or namespace named boost plus a nestted class or namespace named filesystem plsu a nested class or namespace named path.

What does this thing have in it?

Expand|Select|Wrap|Line Numbers
  1. #include "boost/filesystem.hpp" 
  2.  
Also, I would like to see the entire bar.cpp since that is what is being compiled.
May 31 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: AIM | last post by:
Error in msvc in building inheritance.obj to build hello.pyd Hello, I am trying to build the boost 1.31.0 sample extension hello.cpp. I can not compile the file inheritance.cpp because the two...
18
by: perseus | last post by:
It is really crazy! I need to use the Boost filesystem for the manipulation of directories, and I have no idea how to install this filesystem on my IBM-compatible machine. Does anyone up here know...
65
by: perseus | last post by:
I think that everyone who told me that my question is irrelevant, in particular Mr. David White, is being absolutely ridiculous. Obviously, most of you up here behave like the owners of the C++...
6
by: Puzzled | last post by:
This is a weird problem, but perhaps someone else has seen it before (I hope!) If I use a fully qualified include call include ( 'http://localhost/subtree/filename.php') I get an 'undefined...
2
by: jhasse | last post by:
How can I create spaces with the create_directory() function?? When i use this boost::filesystem::create_directory("bla bla"); it throws. When I user ...
1
by: toton | last post by:
In C++ , when the class is declared in the header & not implemented in the cpp, the linker is not giving a error untill the method gets called. How to ensure that all non pure-virtual method...
4
by: Gary Wessle | last post by:
Hi I have been trying to find out the reason for this error for an 1hr, please look at it for me. thanks **************** error **************** $ make; ./proj g++ -gdwarf-2 -c -o...
1
by: Lawrence Spector | last post by:
Base base; BaseWrap& baseWrap(reinterpret_cast<BaseWrap&>(base)); boost::python::object obj(boost::shared_ptr<BaseWrap>(&baseWrap)); // Compile error Results in this error: ...
2
by: Javier | last post by:
Hello all, I'm trying to remove a hidden file (in UNIX) using the Boost::filesystem library. This is what I have: #include <boost/filesystem/operations.hpp> namespace...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.