472,951 Members | 2,035 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,951 software developers and data experts.

Cygwin sockets: getaddrinfo undeclared

83
Im using cygwin to test the code of a server I am writing.
I've included sys/types.h, sys/socket.h, netdb.h, and arpa/inet.h.

And this is the output..
Expand|Select|Wrap|Line Numbers
  1. ../../../sockets.cpp: In constructor `network_class::network_class()':
  2. ../../../sockets.cpp:64: error: aggregate `addrinfo hints' has incomplete type a
  3. nd cannot be defined
  4. ../../../sockets.cpp:69: error: `getaddrinfo' undeclared (first use this functio
  5. n)
  6. ../../../sockets.cpp:69: error: (Each undeclared identifier is reported only onc
  7. e for each function it appears in.)
  8. ../../../sockets.cpp:70: error: `gai_strerror' undeclared (first use this functi
  9. on)
  10. ../../../sockets.cpp: In destructor `network_class::~network_class()':
  11. ../../../sockets.cpp:83: error: `freeaddrinfo' undeclared (first use this functi
  12. on)
  13. main.o:main.cpp:(.text+0x148): undefined reference to `network_class::gethostnam
  14. e()'
  15. collect2: ld returned 1 exit status
I checked the sys/socket file, and it includes cygwin/socket, which doesnt declare any functions. And getaddrinfo is not declared in sys/socket.

I take it I am missing some sort of package, but which one?

(And by the way, is there any other way to tell g++ where to put the .object files rather than being the object dir when running g++?)
Oct 10 '09 #1
7 6633
Adam01
83
Ok turned out I needed to use the -mno-cygwin option for g++.
But help the on the object file directory would be nice.

Edit: Now I seem to be undefined linking errors:

Expand|Select|Wrap|Line Numbers
  1. memoryhandler.o:memoryhandler.cpp:(.text+0xc1c): undefined reference to `_GetPro
  2. cessMemoryInfo@12'
  3. errorhandler.o:errorhandler.cpp:(.text+0xf70): undefined reference to `_WSAGetLa
  4. stError@0'
  5. errorhandler.o:errorhandler.cpp:(.text+0x1840): undefined reference to `_WSAGetL
  6. astError@0'
  7. sockets.o:sockets.cpp:(.text+0xb8): undefined reference to `_WSAStartup@8'
  8. sockets.o:sockets.cpp:(.text+0x139): undefined reference to `_WSACleanup@0'
  9. sockets.o:sockets.cpp:(.text+0x1a9): undefined reference to `_gethostname@8'
  10. sockets.o:sockets.cpp:(.text+0x23c): undefined reference to `_getaddrinfo@16'
  11. sockets.o:sockets.cpp:(.text+0x2ee): undefined reference to `_gethostbyname@4'
  12. sockets.o:sockets.cpp:(.text+0x300): undefined reference to `_inet_ntoa@4'
  13. sockets.o:sockets.cpp:(.text+0x37b): undefined reference to `_gethostname@8'
  14. sockets.o:sockets.cpp:(.text+0x40e): undefined reference to `_getaddrinfo@16'
  15. sockets.o:sockets.cpp:(.text+0x4c0): undefined reference to `_gethostbyname@4'
  16. sockets.o:sockets.cpp:(.text+0x4d2): undefined reference to `_inet_ntoa@4'
  17. sockets.o:sockets.cpp:(.text+0x525): undefined reference to `_freeaddrinfo@4'
  18. sockets.o:sockets.cpp:(.text+0x541): undefined reference to `_freeaddrinfo@4'
  19. collect2: ld returned 1 exit status
I have no idea why WSAstartup is showing up (the function and the header are in #ifdef _WIN32 wrappers.
Oct 10 '09 #2
Adam01
83
Sorry I couldnt edit the post above, but compiling on centOS, compiles and links fine. But running, the only output I get is:
Segmentation fault

No warnings/ouput popped up whilst g++ was compiling/linking.
Oct 10 '09 #3
Adam01
83
Ok delete this thread, I worked it out.
Oct 10 '09 #4
Banfa
9,065 Expert Mod 8TB
Rather than us deleting the thread why don't you post the answer for others to read?
Oct 11 '09 #5
Adam01
83
Ok, I used valgrind to track down the memory errors.

Turns out that gethostbyname("") returned null on centos and I did check it before using it.

I still cant compile this on cygwin.
Oct 11 '09 #6
Banfa
9,065 Expert Mod 8TB
I wish I could help but I have always felt that cygwin was the work of the devil and avoid it as much as possible, hence I don't know much about it, sorry.
Oct 11 '09 #7
Adam01
83
Ok I found out that _WIN32 is defined in cygwin.
And #undef _WIN32 doesnt work >(
Ideas?

Actually I'l use virtualbox.
Oct 11 '09 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: James Hull | last post by:
Hi All: I am new in the Perl world. So far I have installed cygwin and Perl 5.8.0 along with Perl DBI and DBD::Oracle modules. NowI am trying to install Perl Tk on my PC (Windows 2K). I have...
2
by: JustSomeGuy | last post by:
I'm writing a socket class using unix flavor sockets. I'm developing on win2k with M$ visual studio 6.0. I have cygwin installed and would like to use its socket header files: #ifdef UNIX...
4
by: Vish | last post by:
I cannot compile a simple code as below using cygwin. I believe I am using latest version of g++(3.3.1) I get following error is_equal.cpp:9:19: ccc.cpp: No such file or directory...
12
by: Eugene A | last post by:
Hello. I am trying to compile a linux socket server and a client in cygwin on windows. The g++ version is 3.3.1. The source was obtained from this location: ...
6
by: Nadina | last post by:
Hello, I have 3 questions, more or less related. Thank you in advance for your answers! Nadina 1) I am trying to find out if netdb.h exists on my current system. Is "find / -name netdb.h"...
4
by: goberle | last post by:
I have installed the Cygwin package under WinXP. I am trying to insure that I have a reasonable development environment, and that things are working properly, by trying to compile and run the...
12
by: JS | last post by:
I use winXP and have installed Cygwin. I use Dev-C++ and the Cygwin compiler, but for some reason I can't compile this code: #include <setjmp.h> #include <stdio.h> #include <stdlib.h> ...
2
by: Christoph Kukulies | last post by:
Compilation (make, yacc, lex) of little parser used to work fine under BSD (FreeBSD) and now that I want to build it under cygwin, I suddenly get gcc -c y.tab.c y.y: In function `yyparse':...
0
Xx r3negade
by: Xx r3negade | last post by:
I am learning the C interface to protocol-independent sockets, and I'm very confused. For example I keep reading in tutorials to not use sockaddr_in and sockaddr_in6 (since these are...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.