22/03/10 10:41
robrock80
Dato il seguente file header
quando lo includo in più file .cpp il compilatore mi genera il seguente errore
g++ -IC:\Workspaces\Eclipse\C-C++\MY-SHARED-LIBRARY\src -O0 -g3 -Wall -c -fmessage-length=0 -osrc\Client.o ..\src\Client.cpp
g++ -LC:\Workspaces\Eclipse\C-C++\MY-SHARED-LIBRARY\Debug -oclient.exe src\Client.o -lMyShared -lws2_32
C:\Workspaces\Eclipse\C-C++\MY-SHARED-LIBRARY\Debug/libMyShared.a(ClientServerCPP.o): In function `ZSt3minIjERKT_S2_S2_':
/Workspaces/Eclipse/C-C++/MY-SHARED-LIBRARY/Debug/../src/….data+0x0): multiple definition of `SV_MSG_REMOTE_SHELL_CLOSED'
src\Client.o:/Shared/Programmi_portabili/Eclipse-CDT/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/…: first defined here
collect2: ld returned 1 exit status
Build error occurred, build is stopped
Time consumed: 1360 ms.
Qualcuno riesce a capire dov'è il problema?
#ifndef CLIENTSERVERCPP_H_ #define CLIENTSERVERCPP_H_ #include "SystemUtilCPP.h" #include <winsock2.h> #define BUFFER_LENGTH 256 #define SEPARATOR '-' extern const char* SV_MSG_REMOTE_SHELL_CLOSED = "Shell remota chiusa correttamente"; SOCKET initClientSocket(char *, int); void manageRemoteShell(SOCKET, int); SOCKET openServer(int); void openRemtoteShell(SOCKET); void setSocketRecvTimeOut(SOCKET, int, int); void setSocketSendTimeOut(SOCKET, int, int); SOCKET waitForClientConnection(SOCKET); void waitRecv(SOCKET, char *, int, int); #endif
quando lo includo in più file .cpp il compilatore mi genera il seguente errore
g++ -IC:\Workspaces\Eclipse\C-C++\MY-SHARED-LIBRARY\src -O0 -g3 -Wall -c -fmessage-length=0 -osrc\Client.o ..\src\Client.cpp
g++ -LC:\Workspaces\Eclipse\C-C++\MY-SHARED-LIBRARY\Debug -oclient.exe src\Client.o -lMyShared -lws2_32
C:\Workspaces\Eclipse\C-C++\MY-SHARED-LIBRARY\Debug/libMyShared.a(ClientServerCPP.o): In function `ZSt3minIjERKT_S2_S2_':
/Workspaces/Eclipse/C-C++/MY-SHARED-LIBRARY/Debug/../src/….data+0x0): multiple definition of `SV_MSG_REMOTE_SHELL_CLOSED'
src\Client.o:/Shared/Programmi_portabili/Eclipse-CDT/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/…: first defined here
collect2: ld returned 1 exit status
Build error occurred, build is stopped
Time consumed: 1360 ms.
Qualcuno riesce a capire dov'è il problema?
aaa