473,405 Members | 2,379 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 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 6689
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.