473,725 Members | 2,341 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cygwin sockets: getaddrinfo undeclared

83 New Member
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 6721
Adam01
83 New Member
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 New Member
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 New Member
Ok delete this thread, I worked it out.
Oct 10 '09 #4
Banfa
9,065 Recognized Expert Moderator Expert
Rather than us deleting the thread why don't you post the answer for others to read?
Oct 11 '09 #5
Adam01
83 New Member
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 Recognized Expert Moderator Expert
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 New Member
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
4818
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 tried both Tk804.025 and Tk804.025_beta2. However, both versions failed with following errors. It appeared that the command "perl Makefile.PL" ran successfully, but the "make" command failed. I also ran "perl -Mblib demos/widget". It was complaining...
2
12432
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 #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #else // Windows. #include </cygwin/usr/include/sys/types.h>
4
7128
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 is_equal.cpp:11: error: `vector' was not declared in this scope is_equal.cpp:11: error: parse error before `>' token is_equal.cpp: In function `bool equal_vec(...)': is_equal.cpp:12: error: `a' undeclared (first use this function) is_equal.cpp:12: error: (Each...
12
5641
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: http://www.linuxgazette.com/issue74/tougher.html ServerSoccket.cpp apparently compiles OK. Socket.cpp has a problem. Here's
6
4067
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" a solution?
4
13369
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 following classic program. $ cat hellow.cpp #include <iostream> int main (int argc, char *argv) { cout << "Hello, world" << endl;
12
3304
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> typedef int othread_t;
2
4260
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': y.y:17: error: `lfd' undeclared (first use in this function) y.y:17: error: (Each undeclared identifier is reported only once lfd is a static variable which is defined at the end of the .y file,
0
1191
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 protocol-dependent structures), but I *need* to use them in order to use getaddrinfo(). So to start out: below is a function for a host name lookup. Is there any practical way to do this without using the nasty switch statements and the protocol-dependent...
0
8874
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8748
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9092
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8072
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6695
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4506
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3212
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2622
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2151
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.