Somebody Please Please help with linking

General questions regarding the usage of CodeLite
cabacha
CodeLite Curious
Posts: 3
Joined: Sun Feb 08, 2009 3:37 am
Contact:

Somebody Please Please help with linking

Post by cabacha »

Hi All,

I am a newbie to C++ as well as CodeLite. The application that I am building includes
#include "winsock2.h"

I am using gnu gcc compiler and in order to make the executable, I need to somehow link it to "WS2_32.Lib" which is a part of Windows Platform SDK. I have Windows Platform SDK installed on my machine. I went to Project Setting>Linker and set

Library Path: C:/Program Files/Microsoft Platform SDK for Windows XP SP2/Lib
Libraries: WS2_32.Lib

When I build the project, I get

gcc -o ./Debug/ClientServerFileTrans ./Debug/main.o ./Debug/wcomm.o "-LC:/junk/CodeLite/ClientServerFileTrans" -lWS2_32.Lib
C:\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\mingw32\bin\ld.exe: cannot find -lWS2_32.Lib
collect2: ld returned 1 exit status
mingw32-make.exe[1]: *** [Debug/ClientServerFileTrans] Error 1
mingw32-make.exe: *** [All] Error 2


I even tried copying the WS2_32.Lib file to my current project but nothing seems to work. Can somebody please help me in linking this lib file to my build process??????

I'll be very grateful for that.

Thanks
sdolim
CodeLite Veteran
Posts: 69
Joined: Fri Oct 24, 2008 10:29 pm
Contact:

Re: Somebody Please Please help with linking

Post by sdolim »

Hi cabacha,

You need to get the Win32 API that goes with the gcc you are using. The header and library in the MS Platform SDK is for use with Visual C++, not gcc (gcc likes libraries to end in ".a", not ".lib"). You appear to be using MingGW's gcc, so you can find the latest Win32 on their SourceForge download page here:
http://sourceforge.net/project/showfile ... up_id=2435

Scott
cabacha
CodeLite Curious
Posts: 3
Joined: Sun Feb 08, 2009 3:37 am
Contact:

Re: Somebody Please Please help with linking

Post by cabacha »

Hi Scott,

Thanks for your help. I changed the library name in my setting to 'libws2_32.a' (This file was already available in my MinGW installation directory). It looks like I am past that problem. Now it looks like its past that error but now it looks like its unable to find references in the header files.
I also tried using the latest lib and include directories from the link that you specified but still got the same errors.

Any idea about the new reference errors that I am getting? Thanks a lot for your help in advance.....



----------Building project:[ ClientServerFileTrans - Debug ]----------
gcc -c "C:/junk/CodeLite/ClientServerFileTrans/main.cpp" -g -o ./Debug/main.o "-I."
gcc -c "C:/junk/CodeLite/ClientServerFileTrans/wcomm.cpp" -g -o ./Debug/wcomm.o "-I."
In file included from C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/backward/iostream.h:31,
from C:/junk/CodeLite/ClientServerFileTrans/wcomm.h:4,
from C:/junk/CodeLite/ClientServerFileTrans/main.cpp:1:
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.
In file included from C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/backward/iostream.h:31,
from C:/junk/CodeLite/ClientServerFileTrans/wcomm.h:4,
from C:/junk/CodeLite/ClientServerFileTrans/wcomm.cpp:1:
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.
C:/junk/CodeLite/ClientServerFileTrans/wcomm.cpp: In member function `void WComm::waitForClient()':
C:/junk/CodeLite/ClientServerFileTrans/wcomm.cpp:70: warning: converting of negative value `-0x000000001' to `SOCKET'
gcc -o ./Debug/ClientServerFileTrans ./Debug/main.o ./Debug/wcomm.o -lws2_32
./Debug/main.o: In function `ZSt3minIjERKT_S2_S2_':
C:/junk/CodeLite/ClientServerFileTrans/main.cpp:(.text+0xd): undefined reference to `std::string::size() const'
C:/junk/CodeLite/ClientServerFileTrans/main.cpp:(.text+0x60): undefined reference to `std::string::operator[](unsigned int) const'
C:/junk/CodeLite/ClientServerFileTrans/main.cpp:(.text+0x9e): undefined reference to `std::string::operator[](unsigned int) const'
C:/junk/CodeLite/ClientServerFileTrans/main.cpp:(.text+0xcc): undefined reference to `std::string::operator[](unsigned int) const'
./Debug/main.o: In function `Z41__static_initialization_and_destruction_0ii':
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/iostream:77: undefined reference to `std::ios_base::Init::Init()'
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/iostream:77: undefined reference to `std::ios_base::Init::~Init()'
./Debug/wcomm.o: In function `ZSt3minIjERKT_S2_S2_':
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/ios_base.h:(.text+0xd): undefined reference to `std::string::size() const'
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/ios_base.h:(.text+0x60): undefined reference to `std::string::operator[](unsigned int) const'
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/ios_base.h:(.text+0x9e): undefined reference to `std::string::operator[](unsigned int) const'
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/ios_base.h:(.text+0xcc): undefined reference to `std::string::operator[](unsigned int) const'
./Debug/wcomm.o: In function `ZN5WComm8fileSendEPc':
C:/junk/CodeLite/ClientServerFileTrans/wcomm.cpp:145: undefined reference to `__gxx_personality_sj0'
C:/junk/CodeLite/ClientServerFileTrans/wcomm.cpp:154: undefined reference to `std::basic_ifstream<char, std::char_traits<char> >::basic_ifstream(char const*, std::_Ios_Openmode)'
C:/junk/CodeLite/ClientServerFileTrans/wcomm.cpp:155: undefined reference to `std::istream::tellg()'
C:/junk/CodeLite/ClientServerFileTrans/wcomm.cpp:156: undefined reference to `std::basic_ifstream<char, std::char_traits<char> >::close()'
C:/junk/CodeLite/ClientServerFileTrans/wcomm.cpp:194: undefined reference to `std::basic_ifstream<char, std::char_traits<char> >::~basic_ifstream()'
C:/junk/CodeLite/ClientServerFileTrans/wcomm.cpp:194: undefined reference to `std::basic_ifstream<char, std::char_traits<char> >::~basic_ifstream()'
./Debug/wcomm.o: In function `Z41__static_initialization_and_destruction_0ii':
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/iostream:77: undefined reference to `std::ios_base::Init::Init()'
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/iostream:77: undefined reference to `std::ios_base::Init::~Init()'
collect2: ld returned 1 exit status
mingw32-make.exe[1]: *** [Debug/ClientServerFileTrans] Error 1
mingw32-make.exe: *** [All] Error 2
----------Build Ended----------
10 errors, 3 warnings
cabacha
CodeLite Curious
Posts: 3
Joined: Sun Feb 08, 2009 3:37 am
Contact:

Re: Somebody Please Please help with linking

Post by cabacha »

I changed the compiler to gnu ++ and everything is working now.

Thanks for your pointer scott.
Post Reply