[Linker error] undefined reference to `boost::gregorian::greg_month::as_short_string() const'
Hi everyone, I just downloaded boost, built it on windows using cygwin. However, when I tried to run an example program. I got a the following link error [Linker error] undefined reference to `boost::gregorian::greg_month::as_short_string() const' I have added the corresponding lib and include directories to my make file. Is there anything I am missing? Any help will be greatly appreciated. George __________________________________ Do you Yahoo!? Y! Messenger - Communicate in real time. Download now. http://messenger.yahoo.com
On Sun, 19 Sep 2004 01:47:12 -0700 (PDT), Zhoujie Mao wrote
Hi everyone,
I just downloaded boost, built it on windows using cygwin. However, when I tried to run an example program. I got a the following link error
[Linker error] undefined reference to `boost::gregorian::greg_month::as_short_string() const'
I have added the corresponding lib and include directories to my make file.
Is there anything I am missing? Any help will be greatly appreciated.
Sounds like you are using the dynamic lib version of the date-time library. You might try 1) using the static library instead 2) making sure the libboost_date_time.dll is in your search path With number 2 the easiest way is to copy the dll into the same directory as your executable. But really, I think the static lib is the easiest way to go... HTH, Jeff
Hi Jeff, Thanks for the suggestion. I actually was trying to use the static library. I put both the static and dynamic library in a directory, and included the directory in my make file. But obviously, g++ can not find it somehow, are you aware of anything else that could be the problem? Thanks George
Hi everyone,
I just downloaded boost, built it on windows using cygwin. However, when I tried to run an example program. I got a the following link error
[Linker error] undefined reference to `boost::gregorian::greg_month::as_short_string() const'
I have added the corresponding lib and include directories to my make file.
Is there anything I am missing? Any help will be greatly appreciated.
Sounds like you are using the dynamic lib version of the date-time library.
You might try 1) using the static library instead 2) making sure the libboost_date_time.dll is in your search path
With number 2 the easiest way is to copy the dll into the same directory as your executable. But really, I think the static lib is the easiest way to go...
HTH,
Jeff
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users
__________________________________ Do you Yahoo!? Yahoo! Mail - 50x more storage than other providers! http://promotions.yahoo.com/new_mail
On Mon, 20 Sep 2004 10:12:02 -0700 (PDT), Zhoujie Mao wrote
Hi Jeff,
Thanks for the suggestion. I actually was trying to use the static library. I put both the static and dynamic library in a directory, and included the directory in my make file.
I'm not sure what this means, but it needs to be in the link parameters of the command -- see below.
But obviously, g++ can not find it somehow, are you aware of anything else that could be the problem? Thanks
Ok, well if you are using gcc I assume you have something like libboost_date_time-gcc-d-1_31.a as the static lib. You should have a -L switch which points to the directory that file is in and a -lboost_date_time-gcc-d-1_31 So you compile command should look something like: g++ -I${BOOST_ROOT} -L{BOOST_LIB_ROOT} -l boost_date_time-gcc-d-1_31 YOURFILE.cpp -o whatever.exe Jeff
Jeff,
Below is part of my make file
CPP = g++.exe
CC = gcc.exe
WINDRES = windres.exe
RES =
OBJ = main.o $(RES)
LINKOBJ = main.o $(RES)
LIBS = -L"D:/Dev-Cpp499/lib" -L"D:/boost/lib"
-L"D:/boost/lib/libboost_date_time-gcc-1_31.a"
INCS = -I"D:/Dev-Cpp499/include"
CXXINCS = -I"D:/Dev-Cpp499/include/c++/3.3.1"
-I"D:/Dev-Cpp499/include/c++/3.3.1/mingw32"
-I"D:/Dev-Cpp499/include/c++/3.3.1/backward"
-I"D:/Dev-Cpp499/lib/gcc-lib/mingw32/3.3.1/include"
-I"D:/Dev-Cpp499/include"
-I"D:/boost/include/boost-1_31"
BIN = newtest.exe
CXXFLAGS = $(CXXINCS)
CFLAGS = $(INCS)
all: all-before newtest.exe all-after
clean: clean-custom
rm -f $(OBJ) $(BIN)
$(BIN): $(OBJ)
$(CPP) $(LINKOBJ) -o "newtest.exe" $(LIBS)
main.o: main.cpp
$(CPP) -c main.cpp -o main.o $(CXXFLAGS)
I did include the libboost_date_time-gcc-1_31 but it
did not work.
Can you spot something I am not doing correctly?
Thanks for the help.
George
--- Jeff Garland
On Mon, 20 Sep 2004 10:12:02 -0700 (PDT), Zhoujie Mao wrote
Hi Jeff,
Thanks for the suggestion. I actually was trying to use the static library. I put both the static and dynamic library in a directory, and included the directory in my make file.
I'm not sure what this means, but it needs to be in the link parameters of the command -- see below.
But obviously, g++ can not find it somehow, are you aware of anything else that could be the problem? Thanks
Ok, well if you are using gcc I assume you have something like libboost_date_time-gcc-d-1_31.a as the static lib. You should have a -L switch which points to the directory that file is in and a -lboost_date_time-gcc-d-1_31
So you compile command should look something like:
g++ -I${BOOST_ROOT} -L{BOOST_LIB_ROOT} -l boost_date_time-gcc-d-1_31 YOURFILE.cpp -o whatever.exe
Jeff
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users
__________________________________ Do you Yahoo!? Yahoo! Mail - 50x more storage than other providers! http://promotions.yahoo.com/new_mail
Zhoujie Mao wrote:
LIBS = -L"D:/Dev-Cpp499/lib" -L"D:/boost/lib" -L"D:/boost/lib/libboost_date_time-gcc-1_31.a"
The last line is completely wrong. The value of the "-L" option should be a directory, not file. Try LIBS = -L"D:/Dev-Cpp499/lib" -L"D:/boost/lib" -L"D:/boost/lib" -lboost_date_time-gcc-1_31
I did include the libboost_date_time-gcc-1_31 but it did not work. ......
So you compile command should look something like:
g++ -I${BOOST_ROOT} -L{BOOST_LIB_ROOT} -l boost_date_time-gcc-d-1_31 YOURFILE.cpp -o whatever.exe
Does you command line now tools the way Jeff said? And really, you should take the time to learn the tools you use. In particular, -L and -l options are documented in the gcc manual. - Volodya
On Mon, 20 Sep 2004 20:33:51 -0700 (PDT), Zhoujie Mao wrote I'm going to presume the built library file libboost_date_time-gcc-1_31.a is in D:/boost/lib. Please double check that.
Below is part of my make file CPP = g++.exe CC = gcc.exe WINDRES = windres.exe RES = OBJ = main.o $(RES) LINKOBJ = main.o $(RES) LIBS = -L"D:/Dev-Cpp499/lib" -L"D:/boost/lib" -L"D:/boost/lib/libboost_date_time-gcc-1_31.a" ^^^^^^^^^^^^ this looks wrong ^^^^^^^^^^^ change it to the following:
-lboost_date_time-gcc-1_31 so your LIBS line looks like: LIBS = -L"D:/Dev-Cpp499/lib" -L"D:/boost/lib" -lboost_date_time-gcc-1_31
I did include the libboost_date_time-gcc-1_31 but it did not work.
Well, not actually because the -L controls the search path and you can't point it directly to the library.... HTH, Jeff
Thanks Jeff and Vladimir. The problem is gone. But a
new one came up.
[Linker error] undefined reference to
`pthread_mutex_lock'
I guessed I should include libboost-thread-gcc-1_31 as
well. But I only found libboost-thread-gcc-1_31.dll,
is there anyway I can get around this? or I am out of
luck with windows?
George
--- Jeff Garland
On Mon, 20 Sep 2004 20:33:51 -0700 (PDT), Zhoujie Mao wrote
I'm going to presume the built library file libboost_date_time-gcc-1_31.a is in D:/boost/lib. Please double check that.
Below is part of my make file CPP = g++.exe CC = gcc.exe WINDRES = windres.exe RES = OBJ = main.o $(RES) LINKOBJ = main.o $(RES) LIBS = -L"D:/Dev-Cpp499/lib" -L"D:/boost/lib" -L"D:/boost/lib/libboost_date_time-gcc-1_31.a" ^^^^^^^^^^^^ this looks wrong ^^^^^^^^^^^ change it to the following:
-lboost_date_time-gcc-1_31
so your LIBS line looks like:
LIBS = -L"D:/Dev-Cpp499/lib" -L"D:/boost/lib" -lboost_date_time-gcc-1_31
I did include the libboost_date_time-gcc-1_31 but it did not work.
Well, not actually because the -L controls the search path and you can't point it directly to the library....
HTH,
Jeff _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________ Do you Yahoo!? Declare Yourself - Register online to vote today! http://vote.yahoo.com
Zhoujie Mao wrote:
Thanks Jeff and Vladimir. The problem is gone. But a new one came up.
[Linker error] undefined reference to `pthread_mutex_lock'
I guessed I should include libboost-thread-gcc-1_31 as well. But I only found libboost-thread-gcc-1_31.dll, is there anyway I can get around this? or I am out of luck with windows?
Try adding -mthread to the linker command line (I'm not sure about the spelling, for check the docs). Or add -DBOOST_DISABLE_THREADS to the compiler options and rebuild. This assumes you're using gcc 3.3. BTW, it's always a good idea to specify the version of compiler you're using, for gcc it can be obtained with "gcc -v". HTH, Volodya
--- Vladimir Prus
Zhoujie Mao wrote:
Thanks Jeff and Vladimir. The problem is gone. But a new one came up.
[Linker error] undefined reference to `pthread_mutex_lock'
I guessed I should include libboost-thread-gcc-1_31 as well. But I only found libboost-thread-gcc-1_31.dll, is there anyway I can get around this? or I am out of luck with windows?
Try adding -mthread to the linker command line (I'm not sure about the spelling, for check the docs). Or add -DBOOST_DISABLE_THREADS to the compiler options and rebuild. This assumes you're using gcc 3.3.
yes, I am using gcc 3.3. Tried both options, it did not work. Checked gcc manual, could not find out a solution. Thanks. George
BTW, it's always a good idea to specify the version of compiler you're using, for gcc it can be obtained with "gcc -v".
HTH, Volodya
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users
__________________________________ Do you Yahoo!? New and Improved Yahoo! Mail - 100MB free storage! http://promotions.yahoo.com/new_mail
participants (3)
-
Jeff Garland
-
Vladimir Prus
-
Zhoujie Mao