Menu

Compiling troubles

Help
Anonymous
2000-11-28
2001-12-05
  • Anonymous

    Anonymous - 2000-11-28

    Hi there,
    I am trying to build a very basic UDP program, and compiling it happens to be a problem.
    source is something like :
    #include <cc++/socket.h>
    #include <iostream.h>
    #include <stdlib.h>
    #include "calc_udp.h"
    #define PORT 5678
    class myUDPSocket : public UDPSocket{
    public:
    myUDPSocket(InetAddress &ia); };
    myUDPSocket::myUDPSocket(InetAddress &ia) : UDPSocket(ia, PORT) {};
    int main()
    {
    calc_datagram datagram;
    InetAddress addr;
    addr = "127.0.0.1";
    try{
    myUDPSocket server(addr);       
    while(1){
    if( sizeof(datagram) == server.Recv(& datagramme,sizeof(datagram) ) ){
    switch( datagram.op ) {
    case '+':                    datagramme.result=datagramme.a+datagramme.b ;
    break;
    ...etc
    }
    server.Send(& datagramme,sizeof(datagramme));
    ...
    compilation by :
    gcc -pthread -ldl -o a.out servUDPcc++.o -lm -lz -lccxx -lstdc++

    with following flags :
    -D_REENTRANT -D_THREAD_SAFE -O2 -fsigned-char -D_GNU_SOURCE

    And errors are :
    servUDPcc++.o: In function `myUDPSocket::~myUDPSocket(void)':
    /usr/local/include/cc++/socket.h(.text+0x18): undefined reference to `cc_UDPSocket::cc_UDPSocket(cc_InetAddress const &, unsigned short)'
    servUDPcc++.o: In function `main':
    /home/phil/Reseau/UDPCC++/servUDPcc++.cpp:28: undefined reference to `cc_InetAddress::operator=(char const *)'
    /home/phil/Reseau/UDPCC++/servUDPcc++.cpp:29: undefined reference to `operator<<(ostream &, cc_InetAddress const &)'
    /home/phil/Reseau/UDPCC++/servUDPcc++.cpp:52: undefined reference to `cc_Socket type_info node'
    /home/phil/Reseau/UDPCC++/servUDPcc++.cpp:54: undefined reference to `cc_TCPStream type_info node'
    servUDPcc++.o: In function `myUDPSocket::~myUDPSocket(void)':
    /usr/local/include/cc++/socket.h(.gnu.linkonce.t.__tf12cc_UD
    Socket+0x10): undefined reference to `cc_Socket type_info function'
    /usr/local/include/cc++/socket.h(.gnu.linkonce.t.__tf12cc_UDPSocket+0x1a): undefined reference to `cc_Socket type_info node'
    /usr/local/include/cc++/socket.h(.gnu.linkonce.t.__tf12cc_TCPSocket+0x10): undefined reference to `cc_Socket type_info function'
    /usr/local/include/cc++/socket.h(.gnu.linkonce.t.__tf9tcpstream+0x10): undefined reference to `cc_TCPStream type_info function'

    Can anybody help ?

     
    • David Sugar

      David Sugar - 2000-11-28

      First, the link order should be -lccstd -lccio -lccxx -lz and then followed by any thread libs.  Also, you must compile with -rtti.  The "typeinfo node" error usually means the library and the application were compiled under different rtti settings.

       
      • Anonymous

        Anonymous - 2000-11-28

        I'm affraid this did not solve the problem.
        Here is main part of my Makefile :
        MYCODEDIR := .
        CC++DIR := usr/local/include
        SEARCHDIRS := -I- -I${MYCODEDIR} -I${CC++DIR}
        DEPENDFLAGS := -g -D_REENTRANT -D_THREAD_SAFE -O2 -fsigned-char -D_GNU_SOURCE -rtti ${SEARCHDIRS}
        CPPFLAGS = 
        CC     := gcc
        CFLAGS  = ${DEPENDFLAGS}
        %.o : %.cpp
            ${CXX} ${CPPFLAGS} ${CXXFLAGS} -c $< -o $@
        LINKER    := gcc
        LDFLAGS    = -ldl
        LOADLIBES := -lm  -lccstd -lccio -lccxx -lz -pthread
        a.out : ./servUDPcc++.o
            ${LINKER} ${LDFLAGS} -o $@ ${filter-out %.a %.so, $^} ${LOADLIBES}

        I'm affraid Iam not really aware about rtti settings problems...

         
        • Anonymous

          Anonymous - 2000-11-30

          At the moment, my only solution for compiling is to insert my file in the demo directory, and to modify the ./configure created makefile with my prog's name ;-(
          Thanx for helping

           
    • April Lim

      April Lim - 2001-09-13

      I'm having same problem too.
      How you change ./configure ???

      regards,
      April

       
    • prashant patel

      prashant patel - 2001-12-05

      I am having the same linker problem i have tried many possibliliy passing lib parameter lib paramter to g++ flags but nothing works
      ./configure --prefix=/usr
      make
      make install
      all this does not work and david and guys work in a simplified makefiles and ./configuration.
      thanks.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.