Like Tree3Likes

Problem linking a sourceforge project

This is a discussion on Problem linking a sourceforge project within the C Programming forums, part of the General Programming Boards category; I'm trying to compile a sourceforge.net project called MiniWeb HTTP server (it seems abandoned for almost a year). After several ...

  1. #1
    Registered User
    Join Date
    May 2011
    Posts
    4

    Problem linking a sourceforge project

    I'm trying to compile a sourceforge.net project called MiniWeb HTTP server (it seems abandoned for almost a year). After several corrections, I've found a last problem I can't resolve.

    1) I downloaded as tar from SVN.
    2) I applied several corrections (3297135 and 3297167).
    3) I link with:
    Code:
    gcc -lws2_32 httppil.o http.o httpxml.o httphandler.o httppost.o httpauth.o miniweb.o -o miniweb
    And I get:
    Code:
    httppil.o:httppil.c:(.text+0x1b): undefined reference to `WSAStartup@8'
    httppil.o:httppil.c:(.text+0x38): undefined reference to `WSAStartup@8'
    httppil.o:httppil.c:(.text+0x68): undefined reference to `WSACleanup@0'
    http.o:http.c:(.text+0x3a5): undefined reference to `closesocket@4'
    http.o:http.c:(.text+0x5bf): undefined reference to `socket@12'
    http.o:http.c:(.text+0x612): undefined reference to `htons@4'
    http.o:http.c:(.text+0x633): undefined reference to `bind@12'
    http.o:http.c:(.text+0x65e): undefined reference to `listen@8'
    http.o:http.c:(.text+0x83a): undefined reference to `getsockopt@20'
    http.o:http.c:(.text+0xa12): undefined reference to `select@20'
    http.o:http.c:(.text+0xa85): undefined reference to `__WSAFDIsSet@8'
    http.o:http.c:(.text+0xaa3): undefined reference to `__WSAFDIsSet@8'
    http.o:http.c:(.text+0xbac): undefined reference to `__WSAFDIsSet@8'
    http.o:http.c:(.text+0xc85): undefined reference to `ntohl@4'
    http.o:http.c:(.text+0xea7): undefined reference to `accept@12'
    http.o:http.c:(.text+0xf20): undefined reference to `setsockopt@20'
    http.o:http.c:(.text+0x1a73): undefined reference to `recv@16'
    http.o:http.c:(.text+0x246c): undefined reference to `closesocket@4'
    http.o:http.c:(.text+0x2a5b): undefined reference to `send@16'
    http.o:http.c:(.text+0x2a84): undefined reference to `send@16'
    http.o:http.c:(.text+0x2f56): undefined reference to `send@16'
    http.o:http.c:(.text+0x2f86): undefined reference to `send@16'
    http.o:http.c:(.text+0x3122): undefined reference to `send@16'
    http.o:http.c:(.text+0x3253): more undefined references to `send@16' follow
    httphandler.o:httphandler.c:(.text+0x687): undefined reference to `select@20'
    httphandler.o:httphandler.c:(.text+0x6cb): undefined reference to `send@16'
    httppost.o:httppost.c:(.text+0x1a6): undefined reference to `getpeername@12'
    httppost.o:httppost.c:(.text+0x1bd): undefined reference to `ntohl@4'
    httppost.o:httppost.c:(.text+0x1ce): undefined reference to `inet_ntoa@4'
    httppost.o:httppost.c:(.text+0x223): undefined reference to `getpeername@12'
    httppost.o:httppost.c:(.text+0x231): undefined reference to `inet_ntoa@4'
    httppost.o:httppost.c:(.text+0x2ea): undefined reference to `recv@16'
    httpauth.o:httpauth.c:(.text+0x20): undefined reference to `g_httpParam'
    httpauth.o:httpauth.c:(.text+0x2b): undefined reference to `g_httpParam'
    httpauth.o:httpauth.c:(.text+0x4a): undefined reference to `g_httpParam'
    collect2: ld returned 1 exit status
    The name of the library is ws2_32 according to the makefile and to MSDN. I also tried wsock32 and get the same errors. And if I prefixed lib it tells me it can not find it.

    So, I don't know where is the problem.

    PS: If helps:
    OS: Windows XP Professional 2002 SP 3 (Spanish)
    PC: AMD Athlon(tm) 64 X2 Dual Core Processor 3800+ 2.01 GHz, 960 MB RAM
    gcc -v:
    Code:
    Reading specs from C:/Programas/dev-cpp/bin/../lib/gcc/mingw32/3.4.5/specs
    Configured with: ../gcc-3.4.5-20060117-3/configure --with-gcc --with-gnu-ld --with-gnu-as --host=mingw32 --target=mingw32 --prefix=/mingw --enable-threads --disable-nls --enable-languages=c,c++,f77,ada,objc,java --disable-win32-registry --disable-shared --enable-sjlj-exceptions --enable-libgcj --disable-java-awt --without-x --enable-java-gc=boehm --disable-libgcj-debug --enable-interpreter --enable-hash-synchronization --enable-libstdcxx-debug
    Thread model: win32
    gcc version 3.4.5 (mingw-vista special r3)
    Last edited by eloy; 05-03-2011 at 05:36 PM. Reason: Add + info

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    The problem is you are using GCC to compile a Windows program.


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    Quote Originally Posted by quzah View Post
    The problem is you are using GCC to compile a Windows program.

    Quzah.
    I use gcc to compile all my windows programs, and it works just fine.

    OP, are you using Dev-C++?
    bit∙hub [bit-huhb] n. A source and destination for information.

  4. #4
    Registered User
    Join Date
    May 2011
    Posts
    4
    Quote Originally Posted by bithub View Post
    I use gcc to compile all my windows programs, and it works just fine.
    Me too.

    Quote Originally Posted by bithub View Post
    OP, are you using Dev-C++?
    I'm compiling from console, but using the gcc from wxDev-C++ Version Number: build 7.3.1.3.

  5. #5
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    Quote Originally Posted by eloy View Post
    I'm compiling from console, but using the gcc from wxDev-C++ Version Number: build 7.3.1.3.
    I believe that Dev-C++ uses libwsock32.a. Try linking to that and see if it fixes your problem.
    bit∙hub [bit-huhb] n. A source and destination for information.

  6. #6
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by bithub View Post
    I use gcc to compile all my windows programs, and it works just fine.
    Really? Interesting. I am surprised they managed to get all of the MS libraries required to make windows "stuff" work right.

    The more you know... right? (*shooting star*)


    Quzah.
    Hope is the first step on the road to disappointment.

  7. #7
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    Quote Originally Posted by quzah View Post
    Really? Interesting. I am surprised they managed to get all of the MS libraries required to make windows "stuff" work right.

    The more you know... right? (*shooting star*)


    Quzah.
    Yeah, it comes with all the win32 libraries and headers. The project is called MinGW.
    quzah and MK27 like this.
    bit∙hub [bit-huhb] n. A source and destination for information.

  8. #8
    Registered User
    Join Date
    May 2011
    Posts
    4
    Quote Originally Posted by bithub View Post
    I believe that Dev-C++ uses libwsock32.a. Try linking to that and see if it fixes your problem.
    My installation have files libwsock32.a (54 KB) and libws2_32.a (82 KB), and no wsock32.a and ws2_32, but it seems that on gcc I must put not the entire name but only a part (wsock32 or ws2_32). If I tried to put -l libwsock32, -l libwsock32.a, -l libws2_32 or -l libws2_32.a, it tells me that the file cannot be founded.

    So, without the lib, it's like the library was founded but not linked, and with it is not founded.

  9. #9
    Registered User
    Join Date
    May 2011
    Posts
    4
    Anyway, I'm going to home now. I will try with a more recent version of MinGW.

  10. #10
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by quzah View Post
    Really? Interesting. I am surprised they managed to get all of the MS libraries required to make windows "stuff" work right.

    The more you know... right? (*shooting star*)


    Quzah.
    That's no problem... Microsoft gives the libraries and headers away in the Windows SDK....
    quzah likes this.

  11. #11
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by eloy View Post
    I'm trying to compile a sourceforge.net project called

    Ok...small foible with windows... If you are doing a project that needs #include <winsock2.h> you have to list it *before* your #include <windows.h> otherwise you get a cascade of screwy errors and you have to initialize winsock before anything else in your code.

  12. #12
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    Quote Originally Posted by CommonTater View Post
    Ok...small foible with windows... If you are doing a project that needs #include <winsock2.h> you have to list it *before* your #include <windows.h> otherwise you get a cascade of screwy errors and you have to initialize winsock before anything else in your code.
    That would give him compilation errors. In this case he is getting link errors, so he's gotten past that point already. Also, an easier way to fix that compilation error is to define WIN32_LEAN_AND_MEAN so that windows.h doesn't include winsock.h (as well as a bunch of other headers you probably don't need).
    bit∙hub [bit-huhb] n. A source and destination for information.

  13. #13
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by bithub View Post
    That would give him compilation errors. In this case he is getting link errors, so he's gotten past that point already. Also, an easier way to fix that compilation error is to define WIN32_LEAN_AND_MEAN so that windows.h doesn't include winsock.h (as well as a bunch of other headers you probably don't need).
    Then it would seem his linker isn't finding the windows libraries... probably a folder name problem.

    And yes I know about the lean and mean trick but almost all of my projects end up using half the stuff that gets left out...

  14. #14
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,176
    -l libwsock32, -l libwsock32.a, -l libws2_32 or -l libws2_32.a
    It should work anyway if the paths are setup correctly, but GCC by convention uses a short argument style.

    Try the short style: `-lws2_32' for example.

    Microsoft gives the libraries and headers away in the Windows SDK
    Without a valid transferable license to redistribute.

    The MinGW team rebuilt the headers and linker libraries from partly from scratch and partly from a previous effort.

    Soma

  15. #15
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by eloy View Post
    -l libws2_32.a[/FONT], it tells me that the file cannot be founded.
    So, without the lib it's like the library was founded but not linked, and with it is not founded.
    Actually you should take a look in your libraries path... I think you'll find it's ws2_32.lib ... Windows libraries are named *.lib... not *.a

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. EMFPrinter Sourceforge Project Build from Source Code
    By stanlvw in forum Windows Programming
    Replies: 3
    Last Post: 05-27-2008, 02:58 PM
  2. Sourceforge project
    By Scarvenger in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 08-15-2007, 06:23 PM
  3. Linking My Project
    By IdioticCreation in forum C++ Programming
    Replies: 2
    Last Post: 06-04-2007, 05:22 PM
  4. Starting a SourceForge project - need team members
    By ChadJohnson in forum Projects and Job Recruitment
    Replies: 8
    Last Post: 01-05-2006, 01:36 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21