Compile nel sample chatserver, segment fault

Added by gnuser over 4 years ago

Hi,
I used g++ to directly compile the chatserver,

g++ -L/usr/local/lib -lnelmisc -lnelnet -I/usr/local/include/ server.cpp -o server -ldl -lpthread -lxml2

it compiled succeed, but will exit by segment fault when executed.
And I can't understand the Makefile, can anyone give me a hand?


Replies (5)

RE: Compile nel sample chatserver, segment fault - Added by kervala over 4 years ago

Perhaps because you didn't build a multi-threaded application :)

There are 2 ways :
  • use -pthread
  • use -D_REENTRANT and -lpthread

Another problem could be it didn't find its config file, you didn't specify : -DCHAT_DIR=<folder where it could find its chat_service.cfg>

But I suggest you use our makefiles, because as you can notice, you forgot at least 2 parameters. You have choice for NeL, you can use CMake (preferred) or autotools.

RE: Compile nel sample chatserver, segment fault - Added by gnuser over 4 years ago

I use -lpthread to compile. And fro from the log, it find the config file.

Here is the log:
INF b78398e0 command.cpp 145 registerNamedCommandHandler <Unknown> : CCommandRegistry : adding commands handler for class 'CModuleManager'
INF b78398e0 module_manager.cpp 228 addModuleFactoryRegistry <Unknown> : Adding module 'LocalGateway' factory
INF b78398e0 module_manager.cpp 228 addModuleFactoryRegistry <Unknown> : Adding module 'StandardGateway' factory
INF b78398e0 service.cpp 252 cbDirectoryChanged CS : SERVICE: 'ConfigDirectory' changed to '/home/gnuser/game/ryzom/code/nel/samples/net/chat/'
INF b78398e0 service.cpp 252 cbDirectoryChanged CS : SERVICE: 'LogDirectory' changed to '/home/gnuser/game/ryzom/code/nel/samples/net/chat/'
DBG b78398e0 config_file.cpp 388 reparse CS : CF: Adding config file '/home/gnuser/game/ryzom/code/nel/samples/net/chat/chat_service.cfg' in the config file
INF b78398e0 service.cpp 845 main CS : SERVICE: Starting Service 'CS' using NeL (Sep 30 2010 15:32:45) compiled Oct 11 2010 17:14:09
INF b78398e0 service.cpp 846 main CS : SERVICE: On OS: Linux version 2.6.28-11-generic (buildd@palmer) (gcc version 4.3.3 (Ubuntu 4.3.3-5ubuntu4) ) #42-Ubuntu SMP Fri Apr 17 01:57:59 UTC 2009
DBG b78398e0 service.cpp 900 main CS : SERVICE: SIGPIPE Ignored
INF b78398e0 service.cpp 924 main 127.0.1.1/CS : SERVICE: Host: 127.0.1.1
INF b78398e0 command.cpp 145 registerNamedCommandHandler 127.0.1.1/CS : CCommandRegistry : adding commands handler for class 'CUnifiedNetwork'
INF b78398e0 unified_network.cpp 607 init 127.0.1.1/CS : HNETL5: ServerPort is 0 so I don't create a CCallbackServer
Segmentation fault

kervala,
Can you give me some docs or links to learn how to create a simple server project use CMake?

Thx!!

RE: Compile nel sample chatserver, segment fault - Added by kervala over 4 years ago

I don't know if it's related to that, but you should see :

http://stackoverflow.com/questions/875789/gcc-do-i-need-d-reentrant-with-pthreads

With your compilation command, you're building a single threaded application.

-pthread is not -lpthread (notice the l)

I don't understand why you want to create a makefile to compile only chatserver. It's compiled by default with CMake.

RE: Compile nel sample chatserver, segment fault - Added by gnuser over 4 years ago

ok, I use

  • g++ -L/usr/local/lib -lnelmisc -lnelnet -I/usr/local/include/ server.cpp -o server -ldl -lpthread -lxml2 -D_REENTRANT
  • g++ -L/usr/local/lib -lnelmisc -lnelnet -I/usr/local/include/ server.cpp -o server -ldl -pthread -lxml2

The result is the same.

I just want to know how to write some test program to learn more about NeL.
So a simple command to compile a simple test program is enough.
And I am a beginner for write a project use the smart tool like CMake, and I didn't find any docs about how to use the NeL library in a new project under linux(except a doc HelloWorld client from [[http://www.opennel.org/confluence/display/NEL/HelloWorld]]).

Thx again!

RE: Compile nel sample chatserver, segment fault - Added by kervala over 4 years ago

I don't know why it's crashing, I never used it :(

But if you plan to use NeL, you should begin by "misc" samples, there are easier to understand :)

Currently, there is no FindNeL.cmake module to find NeL include path and libraries to link in Hg.

But you can use scripts from : http://code.google.com/p/object-viewer-qt/source/browse/trunk/

Especially :

(1-5/5)