Crystal Space
Welcome, Guest. Please login or register.
April 19, 2014, 04:12:23 am

Login with username, password and session length
Search:     Advanced search
8990 Posts in 2037 Topics by 7597 Members
Latest Member: Drukareczka1989
* Home Help Search Login Register
+  Crystal Space
|-+  Crystal Space Development
| |-+  Support
| | |-+  Linker Error when I try to compile my CS-app...
« previous next »
Pages: [1] Print
Author Topic: Linker Error when I try to compile my CS-app...  (Read 3196 times)
mark
Full Member
***
Posts: 101


View Profile
« on: February 10, 2005, 12:37:21 am »

I created a CS-app based on csApplicationFramework.
Everything worked fine some time ago but now I get linker errors when I try to compile my applicaton.

This is my main-class:
Code:
class Server : public csApplicationFramework {
private:
    iObjectRegistry* objectRegistry;
    csRef<iEngine> engine;
    csRef<iLoader> loader;
    csRef<iVirtualClock> virtualClock;
    csRef<iReporter> reporter;
    csRef<iStandardReporterListener> reporterListener;
    csRef<iCelPlLayer> physiclayer;
    csRef<iCelBlLayer> behavelayer;

    static Network net;

public:
    Server();
    virtual bool OnInitialize(int argc, char* argv[]);
    virtual bool Application();
};


I want to initialize my networking code within Application() between Open() and Run(), but I get the following error:

Code:
g++ -o out/bin/Server src/server/Server.o src/server/network/Network.o  -Lout/lib/crystalspace -Lout/lib/cel -lcstool -lcsgeom -lcsutil -lceltool -lptypes
src/server/Server.o(.text+0xb02): In function `Server::Application()':
: undefined reference to `Server::net'
/usr/lib/gcc/i686-pc-linux-gnu/3.4.3/../../../../i686-pc-linux-gnu/bin/ld: `.L15' referenced in section `.rodata' of out/lib/libcsutil.a(plugmgr.o): defined in discarded section `.gnu.linkonce.t._ZN16csReporterHelper6ReportEP15iObjectRegistryiPKcS3_z' of out/lib/libcsutil.a(plugmgr.o)

/usr/lib/gcc/i686-pc-linux-gnu/3.4.3/../../../../i686-pc-linux-gnu/bin/ld: `.L16' referenced in section `.rodata' of out/lib/libcsutil.a(plugmgr.o): defined in discarded section `.gnu.linkonce.t._ZN16csReporterHelper6ReportEP15iObjectRegistryiPKcS3_z' of out/lib/libcsutil.a(plugmgr.o)

/usr/lib/gcc/i686-pc-linux-gnu/3.4.3/../../../../i686-pc-linux-gnu/bin/ld: `.L18' referenced in section `.rodata' of out/lib/libcsutil.a(plugmgr.o): defined in discarded section `.gnu.linkonce.t._ZN16csReporterHelper6ReportEP15iObjectRegistryiPKcS3_z' of out/lib/libcsutil.a(plugmgr.o)

/usr/lib/gcc/i686-pc-linux-gnu/3.4.3/../../../../i686-pc-linux-gnu/bin/ld: `.L20' referenced in section `.rodata' of out/lib/libcsutil.a(plugmgr.o): defined in discarded section `.gnu.linkonce.t._ZN16csReporterHelper6ReportEP15iObjectRegistryiPKcS3_z' of out/lib/libcsutil.a(plugmgr.o)

/usr/lib/gcc/i686-pc-linux-gnu/3.4.3/../../../../i686-pc-linux-gnu/bin/ld: `.L21' referenced in section `.rodata' of out/lib/libcsutil.a(plugmgr.o): defined in discarded section `.gnu.linkonce.t._ZN16csReporterHelper6ReportEP15iObjectRegistryiPKcS3_z' of out/lib/libcsutil.a(plugmgr.o)

collect2: ld returned 1 exit status


but why? This is crazy, I tried it with and without pointers, I had rewritten 80% of my code to get rid of this error.
Why is it impossible to create a class or use a method in my csApplicationFramework?
I tried OnInitialize() too but then I get the same error.
I *must* be able to create some classes but where?
I hope I don't need to write every class I want to use as a plugin or with SCF...
Logged

Gentoo Linux ~x86, kernel 2.6.11-cko9 smp, gcc 3.4.4-r1, binutils 2.16.1, glibc 2.3.5 NPTL
CS+CEL Pseudo Stable 2005.09.03
mark
Full Member
***
Posts: 101


View Profile
« Reply #1 on: February 10, 2005, 01:49:46 am »

waaaah! Damned cr*p sh*t! After FOURTEEN HOURS (today and several hours this week) I have found the error!
This SHOULD have been documented somewehere.... evil

All class members that are created by me must be pointers.
They must be instanciated in a *separate* method that is called from within Application()

Quote
class Server : public csApplicationFramework {
private:
    iObjectRegistry* objectRegistry;
    csRef<iEngine> engine;
    csRef<iLoader> loader;
    csRef<iVirtualClock> virtualClock;
    csRef<iReporter> reporter;
    csRef<iStandardReporterListener> reporterListener;
    csRef<iCelPlLayer> physiclayer;
    csRef<iCelBlLayer> behavelayer;
 
    Network* net; //this was not a pointer before
 
public:
    Server();
    virtual bool OnInitialize(int argc, char* argv[]);
   void doThisCrap(); // yes, do it!
    virtual bool Application();
};

-------------Server.cpp:------------

void Server::doThisCrap() {
  net = new Network();
  net->foo();
}

Server::Application() {
...
Open();
doThisCrap();  // I had net = new Network() here before
Run();
}


I'm crazy now, this is nuts....
Logged

Gentoo Linux ~x86, kernel 2.6.11-cko9 smp, gcc 3.4.4-r1, binutils 2.16.1, glibc 2.3.5 NPTL
CS+CEL Pseudo Stable 2005.09.03
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 5.661 seconds with 16 queries.