I'm new to c++. Just started learning it 24 hours ago. Am running into a
compile problem. Please, no one waste the effort telling me to google it.
I've been researching it for quite a while with no joy. I got dev-c++ and a
bit of winsock sample code. I've done nothing out of the ordinary. I could
only assume that anyone else that downloaded this software and attempted
this would meet with the same result. The problem lies with either the
compiler or the source. I'm not sure which. Help greatly appreciated.
Compiler output and source to follow.
Compiler: Default compiler
Executing g++.exe...
g++.exe "C:\Documen ts and Settings\d\My Documents\c\tes t.cpp" -o
"C:\Documen ts and Settings\d\My
uments\c\test.e xe" -I"C:\Dev-Cpp\lib\gcc\min gw32\3.4.2\incl ude" -I"C:\Dev-Cpp\include\c++ \3.4.2\backward "
-I"C:\Dev-Cpp\include\c++ \3.4.2\mingw32" -I"C:\Dev-Cpp\include\c++ \3.4.2"
-I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib"
C:\DOCUME~1\D\L OCALS~1\Temp/ccWSaaaa.o:test .cpp:(.text+0x4 6): undefined
reference to `WSAStartup@8'
C:\DOCUME~1\D\L OCALS~1\Temp/ccWSaaaa.o:test .cpp:(.text+0x8 0): undefined
reference to `socket@12'
C:\DOCUME~1\D\L OCALS~1\Temp/ccWSaaaa.o:test .cpp:(.text+0x9 7): undefined
reference to `WSAGetLastErro r@0'
C:\DOCUME~1\D\L OCALS~1\Temp/ccWSaaaa.o:test .cpp:(.text+0xa c): undefined
reference to `WSACleanup@0'
C:\DOCUME~1\D\L OCALS~1\Temp/ccWSaaaa.o:test .cpp:(.text+0xd 0): undefined
reference to `inet_addr@4'
C:\DOCUME~1\D\L OCALS~1\Temp/ccWSaaaa.o:test .cpp:(.text+0xe 5): undefined
reference to `htons@4'
C:\DOCUME~1\D\L OCALS~1\Temp/ccWSaaaa.o:test .cpp:(.text+0x1 0f): undefined
reference to `connect@12'
C:\DOCUME~1\D\L OCALS~1\Temp/ccWSaaaa.o:test .cpp:(.text+0x1 28): undefined
reference to `WSACleanup@0'
C:\DOCUME~1\D\L OCALS~1\Temp/ccWSaaaa.o:test .cpp:(.text+0x1 e5): undefined
reference to `send@16'
C:\DOCUME~1\D\L OCALS~1\Temp/ccWSaaaa.o:test .cpp:(.text+0x2 39): undefined
reference to `recv@16'
collect2: ld returned 1 exit status
Execution terminated
#include <stdio.h>
#include "winsock2.h "
int main() {
// Initialize Winsock.
WSADATA wsaData;
int iResult = WSAStartup( MAKEWORD(2,2), &wsaData );
if ( iResult != NO_ERROR )
printf("Error at WSAStartup()\n" );
// Create a socket.
SOCKET m_socket;
m_socket = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP );
if ( m_socket == INVALID_SOCKET ) {
printf( "Error at socket(): %ld\n", WSAGetLastError () );
WSACleanup();
return 0;
}
// Connect to a server.
sockaddr_in clientService;
clientService.s in_family = AF_INET;
clientService.s in_addr.s_addr = inet_addr( "127.0.0.1" );
clientService.s in_port = htons( 27015 );
if ( connect( m_socket, (SOCKADDR*) &clientServi ce,
sizeof(clientSe rvice) ) == SOCKET_ERROR) {
printf( "Failed to connect.\n" );
WSACleanup();
return 0;
}
// Send and receive data.
int bytesSent;
int bytesRecv = SOCKET_ERROR;
char sendbuf[32] = "Client: Sending data.";
char recvbuf[32] = "";
bytesSent = send( m_socket, sendbuf, strlen(sendbuf) , 0 );
printf( "Bytes Sent: %ld\n", bytesSent );
while( bytesRecv == SOCKET_ERROR ) {
bytesRecv = recv( m_socket, recvbuf, 32, 0 );
if ( bytesRecv == 0 || bytesRecv == WSAECONNRESET ) {
printf( "Connection Closed.\n");
break;
}
if (bytesRecv < 0)
return 0;
printf( "Bytes Recv: %ld\n", bytesRecv );
}
return 0;
} 1 31186
Dom wrote: I'm new to c++. Just started learning it 24 hours ago. Am running into a compile problem. Please, no one waste the effort telling me to google it. I've been researching it for quite a while with no joy.
You'd better wasted a few more time googling it: http://www.google.es/search?hl=gl&q=...Procurar&meta=
Choose the *first* occurence. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Joonas Paalasmaa |
last post by:
Hi,
When compiling Sketch's streamfilter C extension the errors below are
raised during linking. What could cause the errors?
(Python 2.3, MinGw 1.1 with GCC 2.95.3-6, Windows 98)
Here are the occurrences of FilterType that may be relevant:
-------
C:\sketch\sketch-0.7.12\Filter\filterobj.c: 949: PyTypeObject
FilterType = {
|
by: Greg Ewing (using news.cis.dfn.de) |
last post by:
I'm trying to use MingGW32 to compile a Python extension module that
links with the Firebird relational database system.
I've used pexports/dlltool to create a libgds32_ms.a file containing
definitions for linking with gds32.dll, the Firebird interface
library.
All goes well until the linking, when I get
Info: resolving _isc_start_transaction by linking to
|
by: rhzehr |
last post by:
Hi,
I have been having an insane amount of trouble trying to compile a GNU
Scientific Library example with MinGW on WinXP. I have been able to
compile it fine on my linux box and on my windows machine with cygwin.
However, when I try to compile it with MinGW I keep getting this error:
undefined reference to 'gsl_sf_bessel_J0'
I have copied the GSL library files and header files from my cygwin
|
by: ddh |
last post by:
Hi,
I download mingw in my system(XP SP2), and extract them in
c:\mingw\gcc, so the directories looks like: c:\mingw\gcc\bin,
c:\mingw\gcc\include ..., and I added c:\mingw\gcc\bin in my PATH env.
It is OK for compiling .c code, but when compiling c++ code, some
error will occur.
my cpp file:
|
by: JeffCameron |
last post by:
Hi everyone. I am using the latest MinGW that comes with Dev-C++ for
Windows. I am getting an impossible linker error when I try to call
some functions from a library that I wrote. I am avsolutely sure that
the library is linked. I would greatly appreciate a reply from someone
who knows the solution to this problem.
Here is a simplified version of my problem. In order to reproduce the
linking error that I am talking about, use the...
| |
by: newbie73 |
last post by:
Going through the tutorial on http://swig.org, I created the example files
(pasted below). After generating the _wrap file, I tried compiling (using
mingw32) and received a lot of undefined reference compiler errors:
...\build\temp.win32-2.5\Release\example_wrap.o:example_wrap.c:(.text+0x670f):
undefined reference to `_imp__PyExc_MemoryError'
there are many other similar errors all prefaced with _imp__Py, so I am
assuming there is a...
|
by: mani |
last post by:
Hi
I'm bringing up an old story once more! I'm on win32 (winxp sp2)
python 2.4.4. mingw gcc version is 3.4.5. msys is in c:\msys. mingw is
in c:\mingw and python is in c:\pyton24. there is also python24.lib
and libpython24.a in c:\python24\libs.
when I try to compile this sample code from with command in
msys shell I get the results .
this subject was discussed a few times over these years and I tried
everything in the posts and...
|
by: eliben |
last post by:
On Jun 27, 3:10 pm, eliben <eli...@gmail.comwrote:
Problem solved:
http://eli.thegreenplace.net/2008/06/28/compiling-python-extensions-with-distutils-and-mingw/
|
by: LoneWolf |
last post by:
Hi im trying to compile some code im developing that uses opengl and
glut on mingw(using eclipse as the IDE) but im having linker errors
like:
g++ -o(OUTPUT).exe (.o files here) -lopengl32 -lglu32 -lglaux -lglut32
Warning: resolving __imp__glEnable by linking to __imp__glEnable@4
Use --enable-stdcall-fixup to disable these warnings
Use --disable-stdcall-fixup to disable these fixups
Warning: resolving __imp__glBlendFunc by linking to...
|
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...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |