Thread: Linux To FreeBSD Porting Compile Problems

  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    265

    Linux To FreeBSD Porting Compile Problems

    Im trying to get some of my code compiling on more and more platforms, im having trouble with the FreeBSD headers. Right now im using:

    Code:
    #include <netinet/in.h>
    #include <unistd.h>
    #include <sys/types.h>
    #include <sys/socket.h>
    #include <netinet/in.h>
    #include <cerrno>
    #include <netdb.h>
    #include <arpa/inet.h>
    And its spewing errors:

    Code:
    some-box# gcc -o AI_RUN main.cpp -lpthread
    In file included from ../Wrapper Classes/sockets_nix.h:7,
                     from ../Wrapper Classes/sockets.h:44,
                     from botclass.h:22,
                     from main.cpp:6:
    /usr/include/netinet/in.h:235: syntax error before `;'
    /usr/include/netinet/in.h:287: syntax error before `;'
    In file included from /usr/include/netinet/in.h:469,
                     from ../Wrapper Classes/sockets_nix.h:7,
                     from ../Wrapper Classes/sockets.h:44,
                     from botclass.h:22,
                     from main.cpp:6:
    /usr/include/netinet6/in6.h:122: syntax error before `['
    /usr/include/netinet6/in6.h:144: syntax error before `;'
    /usr/include/netinet6/in6.h:149: syntax error before `;'
    /usr/include/netinet6/in6.h:612: syntax error before `*'
    /usr/include/netinet6/in6.h:614: syntax error before `*'
    /usr/include/netinet6/in6.h:615: syntax error before `*'
    /usr/include/netinet6/in6.h:616: syntax error before `*'
    /usr/include/netinet6/in6.h:631: type specifier omitted for parameter
    /usr/include/netinet6/in6.h:632: type specifier omitted for parameter
    /usr/include/netinet6/in6.h:636: syntax error before `*'
    /usr/include/netinet6/in6.h:638: type specifier omitted for parameter
    In file included from ../Wrapper Classes/sockets.h:44,
                     from botclass.h:22,
                     from main.cpp:6:
    ../Wrapper Classes/sockets_nix.h: In method `bool Socket::listen(short unsigned int, int = 128)':
    ../Wrapper Classes/sockets_nix.h:116: `struct sockaddr_in' has no member named `sin_family'
    ../Wrapper Classes/sockets_nix.h:117: `struct sockaddr_in' has no member named `sin_port'
    ../Wrapper Classes/sockets_nix.h:118: `struct in_addr' has no member named `s_addr'
    ../Wrapper Classes/sockets_nix.h: In method `bool Socket::connect(const char *, short unsigned int)':
    ../Wrapper Classes/sockets_nix.h:164: `struct sockaddr_in' has no member named `sin_family'
    ../Wrapper Classes/sockets_nix.h:165: `struct sockaddr_in' has no member named `sin_port'
    Am I including the wrong headers for this platform? Im assuming eventhough headers might be named different, that the functions like connect() take the same parameters.


    Thanks for your time guys.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Try using g++ (not gcc) for compiling your C++ programs
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Feb 2003
    Posts
    265
    Ya, i meant to use that =P although i dont think it made much of a difference:

    Code:
    some-box# g++ -o AI_RUN main.cpp -lpthread
    In file included from ../Wrapper Classes/sockets_nix.h:7,
                     from ../Wrapper Classes/sockets.h:44,
                     from botclass.h:22,
                     from main.cpp:6:
    /usr/include/netinet/in.h:235: syntax error before `;'
    /usr/include/netinet/in.h:287: syntax error before `;'
    In file included from /usr/include/netinet/in.h:469,
                     from ../Wrapper Classes/sockets_nix.h:7,
                     from ../Wrapper Classes/sockets.h:44,
                     from botclass.h:22,
                     from main.cpp:6:
    /usr/include/netinet6/in6.h:122: syntax error before `['
    /usr/include/netinet6/in6.h:144: syntax error before `;'
    /usr/include/netinet6/in6.h:149: syntax error before `;'
    /usr/include/netinet6/in6.h:612: syntax error before `*'
    /usr/include/netinet6/in6.h:614: syntax error before `*'
    /usr/include/netinet6/in6.h:615: syntax error before `*'
    /usr/include/netinet6/in6.h:616: syntax error before `*'
    /usr/include/netinet6/in6.h:631: type specifier omitted for parameter
    /usr/include/netinet6/in6.h:632: type specifier omitted for parameter
    /usr/include/netinet6/in6.h:636: syntax error before `*'
    /usr/include/netinet6/in6.h:638: type specifier omitted for parameter
    In file included from ../Wrapper Classes/sockets.h:44,
                     from botclass.h:22,
                     from main.cpp:6:
    ../Wrapper Classes/sockets_nix.h: In method `bool Socket::listen(short unsigned int, int = 128)':
    ../Wrapper Classes/sockets_nix.h:116: `struct sockaddr_in' has no member named `sin_family'
    ../Wrapper Classes/sockets_nix.h:117: `struct sockaddr_in' has no member named `sin_port'
    ../Wrapper Classes/sockets_nix.h:118: `struct in_addr' has no member named `s_addr'
    ../Wrapper Classes/sockets_nix.h: In method `bool Socket::connect(const char *, short unsigned int)':
    ../Wrapper Classes/sockets_nix.h:164: `struct sockaddr_in' has no member named `sin_family'
    ../Wrapper Classes/sockets_nix.h:165: `struct sockaddr_in' has no member named `sin_port'
    thx for your time S.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    #include <netinet/in.h>
    #include <unistd.h>
    #include <sys/types.h>
    #include <sys/socket.h>
    #include <netinet/in.h>

    The first in.h is a duplicate - perhaps you should remove it
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Feb 2003
    Posts
    265
    Again, thanks for spotting a minor error but it doesnt fix any of the compiler errors. They are still all there.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. pthread and socket porting from Linux to Windows
    By mynickmynick in forum C Programming
    Replies: 2
    Last Post: 07-18-2008, 06:57 AM
  2. wxWidgets, porting from Linux to PDA
    By BobS0327 in forum Tech Board
    Replies: 0
    Last Post: 05-16-2006, 08:25 AM
  3. Newbie problems after first linux install ever...
    By Leeman_s in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 01-24-2003, 03:04 PM
  4. Compilation problems in Linux
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 08-19-2002, 02:01 PM
  5. Compile Problems
    By Eber Kain in forum C++ Programming
    Replies: 1
    Last Post: 08-26-2001, 01:50 PM