Not logged inOpenClonk Forum
Up Topic patch (freebsd) and problems

This board is threaded (i.e. has a tree structure). Please use the Reply button of the specific post you are referring to, not just any random button. If you want to reply to the topic in general, use the Post button near the top and bottom of the page.

Post Reply
In Response to mdg
Hello,

I am trying to make this compile and run on freebsd. Here is my patch so far:

[code]
diff -r fbe2b32500d5 src/C4WinMain.cpp
--- a/src/C4WinMain.cpp  Sun Mar 07 15:16:58 2010 +0100
+++ b/src/C4WinMain.cpp  Thu Mar 11 15:30:13 2010 -0800
@@ -143,6 +143,7 @@
# include <gtk/gtkwindow.h>
#endif

+#ifndef __FreeBSD__
#ifdef HAVE_EXECINFO_H
#include <execinfo.h>

@@ -182,6 +183,7 @@
   _exit(C4XRV_Failure);
   }
#endif
+#endif

#ifdef __APPLE__
void restart(char* args[]) {
@@ -206,6 +208,7 @@
     printf("Do not run %s as root!\n", argc ? argv[0] : "this program");
     return C4XRV_Failure;
     }
+#ifndef __FreeBSD__
#ifdef HAVE_EXECINFO_H
   // Set up debugging facilities
   signal(SIGBUS, crash_handler);
@@ -217,6 +220,7 @@
   signal(SIGFPE, crash_handler);
   signal(SIGTERM, crash_handler);
#endif
+#endif

   // FIXME: This should only be done in developer mode.
#ifdef WITH_DEVELOPER_MODE
diff -r fbe2b32500d5 src/lib/Standard.h
--- a/src/lib/Standard.h  Sun Mar 07 15:16:58 2010 +0100
+++ b/src/lib/Standard.h  Thu Mar 11 15:30:13 2010 -0800
@@ -187,8 +187,10 @@
   #define C4_OS "linux"
#elif defined(__APPLE__)
   #define C4_OS "mac"
+#elif defined(__FreeBSD__)
+  #define C4_OS "freebsd"
#else
-  #define C4_OS "unknown";
+  #define C4_OS "unknown"
#endif

// Color triplets
diff -r fbe2b32500d5 src/network/C4NetIO.cpp
--- a/src/network/C4NetIO.cpp  Sun Mar 07 15:16:58 2010 +0100
+++ b/src/network/C4NetIO.cpp  Thu Mar 11 15:30:13 2010 -0800
@@ -30,30 +30,6 @@
#include <fcntl.h>
#include <sys/stat.h>

-// platform specifics
-#ifdef _WIN32
-
-#include <process.h>
-#include <share.h>
-
-typedef int socklen_t;
-int pipe(int *phandles) { return _pipe(phandles, 10, O_BINARY); }
-
-#else
-
-#include <sys/ioctl.h>
-#include <netinet/in.h>
-#include <netinet/tcp.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <stdlib.h>
-
-#define ioctlsocket ioctl
-#define closesocket close
-#define SOCKET_ERROR (-1)
-
-#endif
-

#ifdef _MSC_VER
#pragma warning (disable : 4355)
diff -r fbe2b32500d5 src/network/C4NetIO.h
--- a/src/network/C4NetIO.h  Sun Mar 07 15:16:58 2010 +0100
+++ b/src/network/C4NetIO.h  Thu Mar 11 15:30:13 2010 -0800
@@ -21,6 +21,34 @@
#ifndef C4NETIO_H
#define C4NETIO_H

+/*
+ matt: Stuff in this file needs netinet/in.h, so I decided to move this here. Probably it should
+ be done somehow else?
+*/
+// platform specifics
+#ifdef _WIN32
+
+#include <process.h>
+#include <share.h>
+
+typedef int socklen_t;
+int pipe(int *phandles) { return _pipe(phandles, 10, O_BINARY); }
+
+#else
+
+#include <sys/ioctl.h>
+#include <netinet/in.h>
+#include <netinet/tcp.h>
+#include <arpa/inet.h>
+#include <netdb.h>
+#include <stdlib.h>
+
+#define ioctlsocket ioctl
+#define closesocket close
+#define SOCKET_ERROR (-1)
+
+#endif
+
#include "StdSync.h"
#include "StdBuf.h"
#include "StdCompiler.h"
[/code]

This builds for me, provided I put -march=i486 in CPPFLAGS, as the default arch for gcc in freebsd is i386, and then it would fail at StdSync.h with an undefined reference to __sync_add_and_fetch_4.

I've blocked out the backtrace, as I think that would have to have freebsd specific code, and I am not sure how that would be done. And I moved a bunch of includes in C4NetIO.h because that file needed netinet/in.h and it wasn't included soon enough. Then I think the apostrophe at the end of   #define C4_OS "unknown"; was causing problems for any other OS than the 3 listed.

It compiled and starts up, but then I have other problems. When I start, it asks for a new player, but then when I put one in it says "open: file not found". And it doesn't seem to save any changes I make in options. So I think it is having path issues. There is no graphic when it starts up, or behind the menu, but maybe there just isn't any yet?

Then when I click 'start game', it starts loading the list of missions, but then seems to hang. A few seconds later it aborts and I get this message in the console:

terminate called after throwing an instance of 'std::runtime_error'
  what():  DirectoryIterator::Read(const char*): Unable to read file system
Abort (core dumped)

Any ideas why?

I havn't yet tried 'make install' - but I would rather get this to work in a user directory first.

Matthew

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill