I have just started learning XmlRpc++ for Dev C++.
When compiling and linking the example program included in the XmlRpc++ DevPak, i reeive this error message:
multiple definition of `vsnprintf'
first defined here
ld returned 1 exit status
C:\Dev-Cpp\Examples\xmlrpcpp\Makefile.win [Build Error] [HelloServer.exe] Error 1
C:/Dev-Cpp/lib/libmingwex.a(mingw_snprintf.o):mingw_snprintf.c:(.text+0x170): multiple definition of `vsnprintf'
../../lib/libxmlrpc.a(XmlRpcUtil.o):XmlRpcUtil.cpp:(.text$vsnprintf[_vsnprintf]+0x0): first defined here
collect2: ld returned 1 exit status
Thank you for your response,
I downloaded the XmlRpc++ includes(aka .h files) and libraries using the Dev C++ WebUpdate tool. These came as packaged files which are then installed using the Dev C++ package manager tool. As for the complier i used the default C++ complier which i believe is a gcc based compiler. As for the snippet of the .h file you included, could I comment that #define vsnprintf out without harming anything?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Unfortunately, I failed to link the code to program. I edited the XmlRpcUtil.h file two separate times. One time it commented out as follows:
//#define vsnprintf _vsnprintf
The build failed and it still returned this message:
multiple definition of `vsnprintf'
first defined here
ld returned 1 exit status
C:\Dev-Cpp\Examples\xmlrpcpp\Makefile.win [Build Error] [HelloServer.exe] Error 1
As for my second attempt at editing XmlRpcUtil.h I edited it as follows:
#indef vsnprintf
#define vsnprintf _vsnprintf
#endif
However, this failed and returned the same message as above.
I think that the problem is in the linked libraries (see below):
../../lib/libxmlrpc.a
../../lib/libws2_32.a
Is there a way to see the source for .a files (Notepad doesn't work- opening them in notepad left parts of them in symbols and the other parts in understandable code)?
If there is a way to edit the .a files what do I do then?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
C:/Dev-Cpp/lib/libmingwex.a(mingw_snprintf.o):mingw_snprintf.c:(.text+0x170): multiple definition of `vsnprintf'
../../lib/libxmlrpc.a(XmlRpcUtil.o):XmlRpcUtil.cpp:(.text$vsnprintf[_vsnprintf]+0x0): first defined here
collect2: ld returned 1 exit status
make.exe: *** [HelloServer.exe] Error 1
Execution terminated
It appears I am having trouble with libmingwex.a, which I didn't include in the linking but it shows up anyway? Is this automatically linked because of the compiler I'm using? The default compiler I use is MingW32. How do I escape the multiple definition error while using this compiler.?
TheDonald
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It worked for me, using the "default" compiler from Dev-C++
Why does it not work for you? The function that gives you the error is included in two different libs, and it is not the same function. Therefore, the linker gives you the error (between libxmlrpc.a and libmingwex.a)
I use Dev-C++ version 4.9.9.2 with several packages installed. I downloaded the XmlRpc lib package named "1mip" and installed in my version of Dev-C++.
I created a new console C++ project, add the libxmlrpc.a and libws2_32.a libs and compiled it. It worked:
Then, i thought, the problem could be the GDI32 lib, because in my first test, I did not include it. So I add it into the project (libgdi32.a). Output (just the linker):
Than, I can think about two options:
1) You are using another compiler than me. My compiler/linker version:
C:\work\xmlrpc\tests>g++ --version
g++ (GCC) 3.4.2 (mingw-special)
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
2) You are using another project type than "console"
José
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am compiling as a "win32 console" according to what it says on my project options.
I am using a newer version of g++
see below:
C:\Documents and Settings\TheDonald>"C:\Dev-Cpp\bin\g++.exe" --version
g++.exe (GCC) 4.1.2
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Download the Devpak for this and try to compile. If you are successful can you give me the full details. Thank you for your attention to my posts.
TheDonald
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Have you attempted to compile with g++.exe (GCC) 4.1.2. It isn't compiling the XmlRpc++ examples for me. I have been waiting for your response.
TheDonald
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I tried to install GCC 4.1.2 and use it for Dev-C++, but I did not get it. I could not get that version of GCC (I only found a 4.2 version, and not through Devpacks) and even using it, I had several problems trying to set Dev-C++.
The only thing I could do is re-install Dev-C++ and set it to use the GCC 4.2, but I will not do it, because I am not sure it will work. Here, the reason:
For Windows, the only version of GCC I found is the one distributed by MinGW, and according to:
there was a change in the MinGW lib that, IMHO, *can* make the XmlRpc++ lib from devpacks not compilable using newer GCC-MinGW compilers. A new version in Devpacks should make the trick.
I cannot help you further
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Well, I solved my problem. I downgraded to the original version of gcc packaged in the Dev-C++ installer and it the example works. It hasn't harmed anything except a few packages I downloaded. Thank you for all your help.
TheDonald
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have just started learning XmlRpc++ for Dev C++.
When compiling and linking the example program included in the XmlRpc++ DevPak, i reeive this error message:
multiple definition of `vsnprintf'
first defined here
ld returned 1 exit status
C:\Dev-Cpp\Examples\xmlrpcpp\Makefile.win [Build Error] [HelloServer.exe] Error 1
Here is the pertinent information:
compile log:
Compiler: Default compiler
Building Makefile: "C:\Dev-Cpp\Examples\xmlrpcpp\Makefile.win"
Finding dependencies for file: C:\Dev-Cpp\Examples\xmlrpcpp\HelloServer.cpp
Executing make...
make.exe -f "C:\Dev-Cpp\Examples\xmlrpcpp\Makefile.win" all
g++.exe -D__DEBUG__ HelloServer.o -o "HelloServer.exe" -L"C:/Dev-Cpp/lib" -lgdi32 -L"C:/Dev-Cpp/include/" -L"C:/Dev-Cpp/lib/" -L"C:/Dev-Cpp/mingw32/lib/" ../../lib/libws2_32.a ../../lib/libxmlrpc.a ../../lib/libwsock32.a ../../lib/gcc/mingw32/4.1.2/libgcc.a ../../lib/libwsock32.a -g3
C:/Dev-Cpp/lib/libmingwex.a(mingw_snprintf.o):mingw_snprintf.c:(.text+0x170): multiple definition of `vsnprintf'
../../lib/libxmlrpc.a(XmlRpcUtil.o):XmlRpcUtil.cpp:(.text$vsnprintf[_vsnprintf]+0x0): first defined here
collect2: ld returned 1 exit status
make.exe: *** [HelloServer.exe] Error 1
Execution terminated
linker files:
../../lib/libws2_32.a
../../lib/libxmlrpc.a
../../lib/libwsock32.a
../../lib/gcc/mingw32/4.1.2/libgcc.a
../../lib/libwsock32.a
library directories:
C:\Dev-Cpp\lib\
C:\Dev-Cpp\include\
C:\Dev-Cpp\mingw32\lib\
include directories:
C:\Dev-Cpp\include\
C:\Dev-Cpp\lib\gcc\mingw32\4.1.2\
Build command:
$(CPP) -c HelloServer.cpp -o HelloServer.o $(CXXFLAGS)
If anyone can tell me how to fix this error i would be very grateful.
TheDonald
Some questions:
Where did you get the xmlrpc++ lib from? From the website and then, compile it? using which compiler?
Notice that, for example, in the XmlRpcUtil.h file, is the following code:
#if defined(_MSC_VER)
# define snprintf _snprintf
# define vsnprintf _vsnprintf /* <--- SEE HERE !!!! */
# define strcasecmp _stricmp
# define strncasecmp _strnicmp
#elif defined(__BORLANDC__)
# define strcasecmp stricmp
# define strncasecmp strnicmp
#endif
Thank you for your response,
I downloaded the XmlRpc++ includes(aka .h files) and libraries using the Dev C++ WebUpdate tool. These came as packaged files which are then installed using the Dev C++ package manager tool. As for the complier i used the default C++ complier which i believe is a gcc based compiler. As for the snippet of the .h file you included, could I comment that #define vsnprintf out without harming anything?
yes, give it a try. If something *wrong* happen, you will notice it by compiling the XmlRpc++ lib (not worries in run time!)
Unfortunately, I failed to link the code to program. I edited the XmlRpcUtil.h file two separate times. One time it commented out as follows:
//#define vsnprintf _vsnprintf
The build failed and it still returned this message:
multiple definition of `vsnprintf'
first defined here
ld returned 1 exit status
C:\Dev-Cpp\Examples\xmlrpcpp\Makefile.win [Build Error] [HelloServer.exe] Error 1
As for my second attempt at editing XmlRpcUtil.h I edited it as follows:
#indef vsnprintf
#define vsnprintf _vsnprintf
#endif
However, this failed and returned the same message as above.
I think that the problem is in the linked libraries (see below):
../../lib/libxmlrpc.a
../../lib/libws2_32.a
Is there a way to see the source for .a files (Notepad doesn't work- opening them in notepad left parts of them in symbols and the other parts in understandable code)?
If there is a way to edit the .a files what do I do then?
I cannot follow what you are doing.
Have you compiled the XmlRpc++ lib by yourself? Which compiler have you used? Or, did you get the lib from a anyone else and use it?
José
I got the lib straight from the source, Devpaks.org. I didn't recompile the lib or do anything to it. Take a look at my compile log.
Compile log:
Compiler: Default compiler
Building Makefile: "C:\Dev-Cpp\Examples\xmlrpcpp\Makefile.win"
Executing make clean
rm -f HelloServer.o HelloServer.exe
g++.exe -c HelloServer.cpp -o HelloServer.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include" -I"C:/Dev-Cpp/include/" -fexceptions
g++.exe HelloServer.o -o "HelloServer.exe" -L"C:/Dev-Cpp/lib" -lgdi32 -L"C:/Dev-Cpp/lib/" ../../lib/libxmlrpc.a ../../lib/libws2_32.a
C:/Dev-Cpp/lib/libmingwex.a(mingw_snprintf.o):mingw_snprintf.c:(.text+0x170): multiple definition of `vsnprintf'
../../lib/libxmlrpc.a(XmlRpcUtil.o):XmlRpcUtil.cpp:(.text$vsnprintf[_vsnprintf]+0x0): first defined here
collect2: ld returned 1 exit status
make.exe: *** [HelloServer.exe] Error 1
Execution terminated
It appears I am having trouble with libmingwex.a, which I didn't include in the linking but it shows up anyway? Is this automatically linked because of the compiler I'm using? The default compiler I use is MingW32. How do I escape the multiple definition error while using this compiler.?
TheDonald
It worked for me, using the "default" compiler from Dev-C++
Why does it not work for you? The function that gives you the error is included in two different libs, and it is not the same function. Therefore, the linker gives you the error (between libxmlrpc.a and libmingwex.a)
I use Dev-C++ version 4.9.9.2 with several packages installed. I downloaded the XmlRpc lib package named "1mip" and installed in my version of Dev-C++.
I created a new console C++ project, add the libxmlrpc.a and libws2_32.a libs and compiled it. It worked:
g++.exe -c HelloServer.cpp -o HelloServer.o -I"C:/Programme/Microsoft SDK 2003/include" -I"C:/Programme/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Programme/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Programme/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Programme/Dev-Cpp/include/c++/3.4.2" -I"C:/Programme/Dev-Cpp/include"
g++.exe HelloServer.o -o "test.exe" -L"C:/Programme/Microsoft SDK 2003/Lib" -L"C:/Programme/Dev-Cpp/lib" ../../../Programme/Dev-Cpp/lib/libxmlrpc.a ../../../Programme/Dev-Cpp/lib/libws2_32.a
And everything was fine
Then, i thought, the problem could be the GDI32 lib, because in my first test, I did not include it. So I add it into the project (libgdi32.a). Output (just the linker):
g++.exe HelloServer.o -o "test.exe" -L"C:/Programme/Microsoft SDK 2003/Lib" -L"C:/Programme/Dev-Cpp/lib" ../../../Programme/Dev-Cpp/lib/libgdi32.a ../../../Programme/Dev-Cpp/lib/libxmlrpc.a ../../../Programme/Dev-Cpp/lib/libws2_32.a
Again, everything was fine.
Than, I can think about two options:
1) You are using another compiler than me. My compiler/linker version:
C:\work\xmlrpc\tests>g++ --version
g++ (GCC) 3.4.2 (mingw-special)
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
2) You are using another project type than "console"
José
I am compiling as a "win32 console" according to what it says on my project options.
I am using a newer version of g++
see below:
C:\Documents and Settings\TheDonald>"C:\Dev-Cpp\bin\g++.exe" --version
g++.exe (GCC) 4.1.2
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Download the Devpak for this and try to compile. If you are successful can you give me the full details. Thank you for your attention to my posts.
TheDonald
Have you attempted to compile with g++.exe (GCC) 4.1.2. It isn't compiling the XmlRpc++ examples for me. I have been waiting for your response.
TheDonald
I'm still waiting for your response about compiling using GCC 4.1.2.
TheDonald
hi donald,
I tried to install GCC 4.1.2 and use it for Dev-C++, but I did not get it. I could not get that version of GCC (I only found a 4.2 version, and not through Devpacks) and even using it, I had several problems trying to set Dev-C++.
The only thing I could do is re-install Dev-C++ and set it to use the GCC 4.2, but I will not do it, because I am not sure it will work. Here, the reason:
For Windows, the only version of GCC I found is the one distributed by MinGW, and according to:
http://sourceforge.net/forum/forum.php?thread_id=1939000&forum_id=240495
there was a change in the MinGW lib that, IMHO, *can* make the XmlRpc++ lib from devpacks not compilable using newer GCC-MinGW compilers. A new version in Devpacks should make the trick.
I cannot help you further
Well, I solved my problem. I downgraded to the original version of gcc packaged in the Dev-C++ installer and it the example works. It hasn't harmed anything except a few packages I downloaded. Thank you for all your help.
TheDonald