Jump to content
  • Advertisement
Sign in to follow this  
graveyard filla

help with errors trying to set up ENet

This topic is 5415 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi, ive recently tried using ENet but cant even get it set up correctly. im using VS.net 2003. the program looks like this:
#ifdef WIN32
#pragma comment(lib, "enet.lib")
#endif
#include "enet.h"
#include <cstdio>


int main (int argc, char ** argv) 
{
    if (enet_initialize() != 0)
    {
        fprintf (stderr, "An error occurred while initializing ENet.\n");
        return 1;
    }
    atexit (enet_deinitialize);

	return 0;
}


now, i get a bunch of errors inside of enet.h.
c:\eNet\win32.h(11) : error C2146: syntax error : missing ';' before identifier 'ENetSocket'
c:\eNet\win32.h(11) : error C2501: 'ENetSocket' : missing storage-class or type specifiers
c:\eNet\win32.h(16) : error C2065: 'INVALID_SOCKET' : undeclared identifier
c:\eNet\enet.h(258) : error C2146: syntax error : missing ';' before identifier 'socket'
c:\eNet\enet.h(258) : error C2501: '_ENetHost::ENetSocket' : missing storage-class or type specifiers
c:\eNet\enet.h(258) : error C2501: '_ENetHost::socket' : missing storage-class or type specifiers
c:\eNet\enet.h(356) : error C2146: syntax error : missing ';' before identifier 'enet_socket_create'
c:\eNet\enet.h(357) : error C2146: syntax error : missing ';' before identifier 'enet_socket_accept'
c:\eNet\enet.h(357) : error C2059: syntax error : ')'
c:\eNet\enet.h(358) : error C2059: syntax error : 'const'
c:\eNet\enet.h(359) : error C2059: syntax error : 'const'
c:\eNet\enet.h(360) : error C2059: syntax error : ','
c:\eNet\enet.h(361) : error C2059: syntax error : ','
c:\eNet\enet.h(362) : error C2182: 'enet_socket_destroy' : illegal use of type 'void'


can anyone help? i didnt build it myself, i got the pre-made package from this site. i stuck this folder in my C: directory and included it in my library and include directories in my VS settings. thanks a lot for any help.

Share this post


Link to post
Share on other sites
Advertisement
the header file win32.h in that enet distribution is wrong, remove the comments from:


/*#include <stdlib.h>
#include <winsock2.h> */


Share this post


Link to post
Share on other sites
A quote from a prior post of mine...
Quote:

Found the error… turns out I was on the right track anyhow. It seems that after building Enet as a library and adding it to your project (including enet.h as you do) you must also include the provided win32.h and win32.c within your workspace (above your inclusion of enet.h - and these files must actually be loaded into your workspace in the caset that you are using MSVC++).
The extra includes are, for some odd reason, not mentioned anywhere in the documentation despite the fact that it is a known issue with MSVC++.
Also note in future that it be neccissary that you #define _WINSOCKAPI_ before including windows.h in your projects that make use of Enet. This is not addressed in the documentation either. All cleared up…


Hope this helps,
Jackson Allan

[Edited by - jack_1313 on September 23, 2004 1:56:35 AM]

Share this post


Link to post
Share on other sites
thanks everybody,

i had to un-comment those 2 lines and also include the ws2_32.lib.... adding the header to my project and doing that #define didnt seem to do anything. (i think?)

Share this post


Link to post
Share on other sites
hi,

im getting problems again. i tried getting ENet into my game, but am getting linking errors. i think that the .lib file or something with ENet is conflicting with my setup. heres the errors:


network.obj : error LNK2001: unresolved external symbol __RTC_Shutdown
main1.obj : error LNK2001: unresolved external symbol __RTC_Shutdown
network.obj : error LNK2001: unresolved external symbol __RTC_InitBase
main1.obj : error LNK2001: unresolved external symbol __RTC_InitBase
network.obj : error LNK2019: unresolved external symbol _enet_packet_destroy referenced in function "public: void __thiscall Network_Server::Update(void)" (?Update@Network_Server@@QAEXXZ)
network.obj : error LNK2019: unresolved external symbol _printf referenced in function "public: void __thiscall Network_Server::Update(void)" (?Update@Network_Server@@QAEXXZ)
main1.obj : error LNK2001: unresolved external symbol _printf
network.obj : error LNK2019: unresolved external symbol _enet_host_service referenced in function "public: void __thiscall Network_Server::Update(void)" (?Update@Network_Server@@QAEXXZ)
network.obj : error LNK2019: unresolved external symbol __RTC_CheckEsp referenced in function "public: void __thiscall Network_Server::Update(void)" (?Update@Network_Server@@QAEXXZ)
main1.obj : error LNK2019: unresolved external symbol __RTC_CheckEsp referenced in function _SDL_main
network.obj : error LNK2019: unresolved external symbol @_RTC_CheckStackVars@8 referenced in function "public: void __thiscall Network_Server::Update(void)" (?Update@Network_Server@@QAEXXZ)
main1.obj : error LNK2019: unresolved external symbol @_RTC_CheckStackVars@8 referenced in function _SDL_main
network.obj : error LNK2019: unresolved external symbol _exit referenced in function "public: void __thiscall Network_Client::Init(int,int)" (?Init@Network_Client@@QAEXHH@Z)
main1.obj : error LNK2019: unresolved external symbol _exit referenced in function "int __cdecl InitImages(void)" (?InitImages@@YAHXZ)
network.obj : error LNK2019: unresolved external symbol _enet_host_create referenced in function "public: void __thiscall Network_Client::Init(int,int)" (?Init@Network_Client@@QAEXHH@Z)
main1.obj : error LNK2001: unresolved external symbol __fltused
main1.obj : error LNK2019: unresolved external symbol _SDL_GetTicks referenced in function _SDL_main
main1.obj : error LNK2019: unresolved external symbol _srand referenced in function _SDL_main
main1.obj : error LNK2019: unresolved external symbol _SDL_SetColorKey referenced in function "int __cdecl InitImages(void)" (?InitImages@@YAHXZ)
main1.obj : error LNK2019: unresolved external symbol _SDL_MapRGB referenced in function "int __cdecl InitImages(void)" (?InitImages@@YAHXZ)
main1.obj : error LNK2019: unresolved external symbol _IMG_Load referenced in function "int __cdecl InitImages(void)" (?InitImages@@YAHXZ)
main1.obj : error LNK2019: unresolved external symbol _SDL_UpperBlit referenced in function "void __cdecl DrawIMG(struct SDL_Surface *,int,int)" (?DrawIMG@@YAXPAUSDL_Surface@@HH@Z)
main1.obj : error LNK2019: unresolved external symbol __ftol2 referenced in function "void __cdecl DrawBG(void)" (?DrawBG@@YAXXZ)
main1.obj : error LNK2019: unresolved external symbol _SDL_Flip referenced in function "void __cdecl Draw_Objects(void)" (?Draw_Objects@@YAXXZ)
main1.obj : error LNK2019: unresolved external symbol _SDL_WM_SetCaption referenced in function "void __cdecl InitSDL(void)" (?InitSDL@@YAXXZ)
main1.obj : error LNK2019: unresolved external symbol _SDL_SetVideoMode referenced in function "void __cdecl InitSDL(void)" (?InitSDL@@YAXXZ)
main1.obj : error LNK2019: unresolved external symbol _SDL_WM_SetIcon referenced in function "void __cdecl InitSDL(void)" (?InitSDL@@YAXXZ)
main1.obj : error LNK2019: unresolved external symbol _SDL_LoadBMP_RW referenced in function "void __cdecl InitSDL(void)" (?InitSDL@@YAXXZ)
main1.obj : error LNK2019: unresolved external symbol _SDL_RWFromFile referenced in function "void __cdecl InitSDL(void)" (?InitSDL@@YAXXZ)
main1.obj : error LNK2019: unresolved external symbol _atexit referenced in function "void __cdecl InitSDL(void)" (?InitSDL@@YAXXZ)
main1.obj : error LNK2019: unresolved external symbol _SDL_Quit referenced in function "void __cdecl InitSDL(void)" (?InitSDL@@YAXXZ)
main1.obj : error LNK2019: unresolved external symbol _SDL_GetError referenced in function "void __cdecl InitSDL(void)" (?InitSDL@@YAXXZ)
main1.obj : error LNK2019: unresolved external symbol _SDL_Init referenced in function "void __cdecl InitSDL(void)" (?InitSDL@@YAXXZ)
main1.obj : error LNK2019: unresolved external symbol _rand referenced in function "void __cdecl Do_Glove_Movement(void)" (?Do_Glove_Movement@@YAXXZ)
main1.obj : error LNK2019: unresolved external symbol _SDL_GetKeyState referenced in function "void __cdecl Do_Glove_Movement(void)" (?Do_Glove_Movement@@YAXXZ)
main1.obj : error LNK2019: unresolved external symbol _SDL_PollEvent referenced in function "void __cdecl Do_Glove_Movement(void)" (?Do_Glove_Movement@@YAXXZ)
main1.obj : error LNK2019: unresolved external symbol _Mix_PlayChannelTimed referenced in function "void __cdecl Do_All_Collision(void)" (?Do_All_Collision@@YAXXZ)
main1.obj : error LNK2019: unresolved external symbol _Mix_AllocateChannels referenced in function "void __cdecl InitAudio(void)" (?InitAudio@@YAXXZ)
main1.obj : error LNK2019: unresolved external symbol _Mix_LoadMUS referenced in function "void __cdecl InitAudio(void)" (?InitAudio@@YAXXZ)
main1.obj : error LNK2019: unresolved external symbol _Mix_LoadWAV_RW referenced in function "void __cdecl InitAudio(void)" (?InitAudio@@YAXXZ)
main1.obj : error LNK2019: unresolved external symbol _Mix_OpenAudio referenced in function "void __cdecl InitAudio(void)" (?InitAudio@@YAXXZ)
main1.obj : error LNK2019: unresolved external symbol _Mix_CloseAudio referenced in function "void __cdecl Close_Audio(void)" (?Close_Audio@@YAXXZ)
main1.obj : error LNK2019: unresolved external symbol _Mix_FreeMusic referenced in function "void __cdecl Close_Audio(void)" (?Close_Audio@@YAXXZ)
main1.obj : error LNK2019: unresolved external symbol _Mix_HaltMusic referenced in function "void __cdecl Close_Audio(void)" (?Close_Audio@@YAXXZ)
main1.obj : error LNK2019: unresolved external symbol _Mix_FreeChunk referenced in function "void __cdecl Close_Audio(void)" (?Close_Audio@@YAXXZ)
main1.obj : error LNK2019: unresolved external symbol _Mix_PlayMusic referenced in function "void __cdecl Do_Intro_Screen(void)" (?Do_Intro_Screen@@YAXXZ)
LINK : error LNK2001: unresolved external symbol _mainCRTStartup
Debug/net_test.exe : fatal error LNK1120: 41 unresolved externals



does anyone know what the problem is? i tried building Enet myself, too, but still have the same problem. thanks for any help.

Share this post


Link to post
Share on other sites
Here is how I got Enet working. This is a client / server based Windows chat program that I was working on before I converted to HawkNL for the enhanced control provided (HawkNL is lower-level than Enet). Be warned – this program is incomplete and, having not looked at it for a while, is probably coded quite badly. Also note that I cannot get this program to work on Win98 or WinMe computers. I do, however, believe that this is a problem related to my machine and compiler and not my Enet configuration as my HawkNL programs also crash (on Windows 98) upon connection.

Anyhow, I hope this works for you,
Jackson Allan

Share this post


Link to post
Share on other sites
thanks a lot jack. that example will help me a lot. what compiler / IDE are you using? did you build it yourself? i still cant get it to compile, im getting these weird linker errors, like as if one of the headers i include is conflicting with something Enet is doing....

thanks a lot for anymore help.

Share this post


Link to post
Share on other sites
I am using Microsoft Visual C++ 6.0 and I did build the Enet lib myself - only because I couldn’t seem to find a pre-compiled version (do be sure that ENET_DLL is not defined in enet.h).
Those link errors are rather odd because many of them do not seem to have relation with Enet. Have you check the Enet mailing list archives for a possible solution? Other than that, I can only point out that I needed to #define _WINSOCKAPI_ before *all* #include "windows.h" in my project. However, the my compiler was generating differed vastly from those you have listed. Try compiling an Enet program without SDL and see if it works?

Anyhow, hope this goes well for you,
Jackson Allan

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!