Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Compilation failures on Linux.  (Read 1820 times)

0 Members and 1 Guest are viewing this topic.

BackwardSpy

  • Newbie
  • *
  • Posts: 5
    • View Profile
Compilation failures on Linux.
« on: January 19, 2015, 12:25:25 am »
Hi! I have been searching around for the cause of this issue all day, so excuse me if this question has been answered anywhere; because I haven't found it yet!
There have been a few references to this issue, but no solutions as far as I can tell.

I have a project that I am working on a Linux port for. The project uses SFML's networking module, but I am posting in this section because (judging by other posts) the issue seems to be unrelated to specific modules in SFML.

Here's the error output:
g++ -Wno-attributes -std=c++11 -c main.cpp -o main.o
In file included from XWindow.h:6:0,
                 from Window.h:18,
                 from main.cpp:2:
/usr/include/SFML/Network/Socket.hpp:53:10: error: expected identifier before ‘int’
     enum Status
          ^
In file included from /usr/include/SFML/Network/TcpSocket.hpp:32:0,
                 from /usr/include/SFML/Network/Ftp.hpp:32,
                 from /usr/include/SFML/Network.hpp:33,
                 from SFMLPacket.h:3,
                 from main.cpp:20:
/usr/include/SFML/Network/Socket.hpp:54:5: error: expected unqualified-id before ‘{’ token
     {
     ^
In file included from XWindow.h:6:0,
                 from Window.h:18,
                 from main.cpp:2:
/usr/include/SFML/Network/Ftp.hpp:74:14: error: expected identifier before ‘int’
         enum Status
              ^
In file included from /usr/include/SFML/Network.hpp:33:0,
                 from SFMLPacket.h:3,
                 from main.cpp:20:
/usr/include/SFML/Network/Ftp.hpp:75:9: error: expected unqualified-id before ‘{’ token
         {
         ^
In file included from /usr/include/SFML/Network.hpp:33:0,
                 from SFMLPacket.h:3,
                 from main.cpp:20:
/usr/include/SFML/Network/Ftp.hpp:146:41: error: ‘InvalidResponse’ was not declared in this scope
         explicit Response(Status code = InvalidResponse, const std::string& message = "");
                                         ^
In file included from /usr/include/X11/Xlib.h:44:0,
                 from XWindow.h:6,
                 from Window.h:18,
                 from main.cpp:2:
/usr/include/SFML/Network/IpAddress.hpp:184:28: error: expected unqualified-id before numeric constant
     static const IpAddress None;      ///< Value representing an empty/invalid address
                            ^
In file included from XWindow.h:6:0,
                 from Window.h:18,
                 from main.cpp:2:
/usr/include/SFML/Network/Http.hpp:201:14: error: expected identifier before ‘int’
         enum Status
              ^
In file included from /usr/include/SFML/Network.hpp:34:0,
                 from SFMLPacket.h:3,
                 from main.cpp:20:
/usr/include/SFML/Network/Http.hpp:202:9: error: expected unqualified-id before ‘{’ token
         {
         ^
makefile:19: recipe for target 'main.o' failed
make: *** [main.o] Error 1
 

There are, of course, many other files in the project. However, they compile without issue.
I have checked the relevant file in my project (SFMLPacket.h) but I see no problems in there. It seems to be the fact that it includes SFML/Network.hpp rather than an issue in our code.

I highly doubt it's a legitimate error in SFML's code (it would have been noticed by now!), so is this some kind of incompatibility with other Linux headers or something? What can I do about fixing it?

Thank you very much.

FRex

  • Hero Member
  • *****
  • Posts: 1845
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Compilation failures on Linux.
« Reply #1 on: January 19, 2015, 12:37:11 am »
Headers of X11 define some idiotic things like 'Status', 'None' and possibly more, to some types/constants.
Back to C++ gamedev with SFML in May 2023

BackwardSpy

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Compilation failures on Linux.
« Reply #2 on: January 19, 2015, 12:41:12 am »
I feared it might be something like that. What can I do to work around this? Moving the SFML includes in such a way that they are included first sounds doable, but difficult given the project structure. Is there any other way?

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Compilation failures on Linux.
« Reply #3 on: January 19, 2015, 12:45:52 am »
The only other solution I know of is strategically #undef'ing all the macros that X11 is using to break SFML.

BackwardSpy

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Compilation failures on Linux.
« Reply #4 on: January 19, 2015, 01:41:47 am »
I went ahead and spent a while fixing the include structure/order of the project. It works! Thank you for your help. It's a damn shame X11 has such glaring problems in it.

 

anything