Author Topic: Compiling on Cygwin  (Read 27882 times)

battlesquid

  • Guest
Compiling on Cygwin
« on: June 30, 2010, 12:59:00 am »
I'm trying to make this project without using visual studio (just not interested in using that), but I'm having some problems. I fetched the code, installed SDL (devel) to resolve the sdl-config dependency in openxcom Makefile.

The Makefile somehow doesn't expand backticks for me using borland make 5.2 in cygwin. I got the following error:


$ make
MAKE Version 5.2  Copyright (c) 1987, 2000 Borland
        `sdl-config --libs` -lSDL_gfx -lSDL_mixer -o openxcom
'`sdl-config' is not recognized as an internal or external command,
operable program or batch file.

** error 1 ** deleting openxcom


so I edited those lines using the output I got into:


CXXFLAGS = -Wall -O2 -I/usr/local/include/SDL -D_GNU_SOURCE=1 -Dmain=SDL_main
LDFLAGS = -L/usr/local/lib -lmingw32 -lSDLmain -lSDL -mwindows -lSDL_gfx -lSDL_mixer


and got rid of that, but still no go:


$ make
MAKE Version 5.2  Copyright (c) 1987, 2000 Borland
        L/usr/local/lib -lmingw32 -lSDLmain -lSDL -mwindows -lSDL_gfx -lSDL_mixer -o openxcom
Fatal: Unable to execute command: L/usr/local/lib


It seems to me that at the line

$(CXX) $(LDFLAGS) -o $(PROG) $(OBJS)

CXX is not set, so it tries to execute a command  L/usr/local/lib

I'm not familiar with Makefiles so I don't know what's wrong.

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2160
    • View Profile
Compiling on Cygwin
« Reply #1 on: June 30, 2010, 01:29:03 am »
I'm not familiar with cygwin so I don't know why it wouldn't have the CXX variable set by default, but just putting "CXX = g++" yourself at the top of the makefile should fix it.

Offline Eeyoocah5Moh

  • Sergeant
  • **
  • Posts: 28
    • View Profile
Compiling on Cygwin
« Reply #2 on: June 30, 2010, 05:00:04 am »
The Makefile somehow doesn't expand backticks for me using borland make 5.2 in cygwin.

Why you are using borland make? You should use GNU make. AFAIK there is GNU make included in cygwin, you should just install it.

battlesquid

  • Guest
Compiling on Cygwin
« Reply #3 on: June 30, 2010, 10:08:34 pm »
I tried to set CXX=g++ in the shell however had to do it inside the Makefile (probably starts a new subshell?)
I haven't installed GNU make, simply because then I have to upgrade cygwin. I will if I have to though. Right now (after setting CXX=g++) I get:

$ make
MAKE Version 5.2  Copyright (c) 1987, 2000 Borland
        g++ -L/usr/local/lib -lmingw32 -lSDLmain -lSDL -mwindows -lSDL_gfx -lSDL_mixer -o openxcom
c:\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\mingw32\bin\ld.exe: cannot find -lSDLmain
collect2: ld returned 1 exit status

** error 1 ** deleting openxcom


as you can see I have installed mingw (wtf is up with the relative path there... maybe that's a clue), and it reports that it cannot fin -lSDLmain for some reason.

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2160
    • View Profile
Compiling on Cygwin
« Reply #4 on: July 01, 2010, 04:11:17 am »
Doesn't look like you installed SDL properly. Check if the libraries are in the respective folders and the paths are right, maybe you forgot a step. These links might help:

https://www.libsdl.org/extras/win32/cygwin/README.txt
https://www.devolution.com/pipermail/sdl/2002-February/042594.html

And remember you won't need just SDL but also SDL_mixer and SDL_gfx.

battlesquid

  • Guest
Compiling on Cygwin
« Reply #5 on: July 02, 2010, 12:09:28 am »
Probably SDL isn't installed properly. I started from scratch and followed the guide. At make i get an error


asn@dingo ~/dev/sdl/SDL-1.2.14
$ make
MAKE Version 5.2  Copyright (c) 1987, 2000 Borland
Error makefile 77: Command syntax error
*** 1 errors during make ***


I suspect this has something to do with not using GCC so I'll try installing that first.

asn@dingo ~/dev/sdl/SDL-1.2.14
$ type make
make is hashed (/cygdrive/c/Borland/BCC55/Bin/make)


battlesquid

  • Guest
Compiling on Cygwin
« Reply #6 on: July 02, 2010, 01:15:43 am »
Installing GNU make and reinstalling SDL made progress, thankfully. Still I get an error and a whole lot of warnings. The last lines of output:


...

Music.h:35: error: ISO C++ forbids declaration of `Mix_Music' with no type
Music.h:35: error: expected `;' before '*' token

...
Bar.h:65:7: warning: no newline at end of file
In file included from BaseInfoState.h:30,
                 from BasescapeState.h:32,
                 from GeoscapeState.h:36,
                 from NewGameState.h:28,
                 from MainMenuState.h:28,
                 from AbandonGameState.h:29,
                 from AbandonGameState.cpp:19:
TextEdit.h:75:7: warning: no newline at end of file
AbandonGameState.cpp:90:2: warning: no newline at end of file
make: *** [AbandonGameState.o] Error 1


The full output here https://pastebin.ca/1893077


The warnings are probably nothing to worry about, but the error I have to sort out. Maybe this error is related to SDL_mixer... The dependency resolving continues... Tomorrow.

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2160
    • View Profile
Compiling on Cygwin
« Reply #7 on: July 02, 2010, 02:36:27 am »
Yeah all the errors are from SDL_mixer and SDL_gfx missing, once you sort those out you should be settled.

battlesquid

  • Guest
Compiling on Cygwin
« Reply #8 on: July 02, 2010, 09:50:51 pm »
I've installed latest SDL_mixer and SDL_gfx and got no errors doing so. Still I get an error making openxcom https://pastebin.com/huYsmmHG

There's no lines other than the last one saying error. They're all warnings it appears. Did I miss something? What can I do to find the error?

--Edit--
The only thing I can think of (and maybe that's enough)

Screen.h:23:26: SDL_rotozoom.h: No such file or directory
SDL_gfxPrimitives.h: No such file or directory


Those two files not found is probably a bad thing. But why wouldn't it find them...
« Last Edit: July 03, 2010, 12:05:32 am by battlesquid »

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2160
    • View Profile
Compiling on Cygwin
« Reply #9 on: July 03, 2010, 01:16:22 am »
It's still not finding SDL_gfx. These are the steps for compiling it on Linux from the SDL_gfx source folder:

Code: [Select]
./autogen.sh    (optional)
./configure
make
make install
ldconfig

I assume the same works on cygwin. Make sure the library is in /usr/local/lib and the include files are in /usr/local/include (or equivalent in cygwin), they're the ones popping up on the error messages.

battlesquid

  • Guest
Compiling on Cygwin
« Reply #10 on: July 03, 2010, 05:12:15 pm »
Everything up to ldconfig went fine, but it cannot find ldconfig. I did a search for cygwin + ldconfig and here it says it isn't needed under windows:
https://www.cygwin.com/ml/cygwin/2002-03/msg00798.html

As the first step was marked 'optional' I thought I had made no progress with this, but apparently running autogen was not optional for me, because I made a lot of progress. It looked like it would be a complete build, but unfortunately not there yet. The output from make was so long it used up my screen buffer and some was cut off. I searched through it for 'error' and 'no such file' but got no hits. The last two lines were:

collect2: ld returned 1 exit status
make: *** [openxcom] Error 1


I don't know what collect2 means. Everything else seems to be warnings, but it's hard to tell since the logging is so flooded with warnings. How can I adjust verbosity or ignoring warnings with make? I didn't find anything applicable with make --help...

Offline michal

  • Commander
  • *****
  • Posts: 629
    • View Profile
Compiling on Cygwin
« Reply #11 on: July 03, 2010, 05:31:56 pm »
Maybe you will have more luck with mingw + msys (this should contain make). It's alternative solution to cygwin. Unfortunately i don't have experience in both solutions, so i can't tell if it's better or if it help you.

https://www.mingw.org/

battlesquid

  • Guest
Compiling on Cygwin
« Reply #12 on: July 03, 2010, 05:42:44 pm »
I did some research on the resulting objects and it seems although I got an error at the end, there were as many .o files as .h files which makes me think make did what it was supposed to
https://imagebin.ca/img/bPVxkQg.gif

So how do I go from these object files into OpenXcom.exe?

Running gcc *.o -o OpenXcom.exe gave me 'undefined reference' all over the place

main.o:main.cpp:(.text+0x63c): undefined reference to `std::ios_base::Init::Init()'
main.o:main.cpp:(.text+0x658): undefined reference to `std::ios_base::Init::~Init()'
main.o:main.cpp:(.gcc_except_table+0x28): undefined reference to `typeinfo for char*'
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../libcygwin.a(libcmain.o):(.text+0xa9): undefined reference to `_WinMain@16'
collect2: ld returned 1 exit status


...but that might not be the right way to do it anyway
« Last Edit: July 03, 2010, 09:53:35 pm by battlesquid »

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2160
    • View Profile
Compiling on Cygwin
« Reply #13 on: July 04, 2010, 09:55:46 pm »
I did some research on the resulting objects and it seems although I got an error at the end, there were as many .o files as .h files which makes me think make did what it was supposed to
https://imagebin.ca/img/bPVxkQg.gif

So how do I go from these object files into OpenXcom.exe?

Running gcc *.o -o OpenXcom.exe gave me 'undefined reference' all over the place

main.o:main.cpp:(.text+0x63c): undefined reference to `std::ios_base::Init::Init()'
main.o:main.cpp:(.text+0x658): undefined reference to `std::ios_base::Init::~Init()'
main.o:main.cpp:(.gcc_except_table+0x28): undefined reference to `typeinfo for char*'
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../libcygwin.a(libcmain.o):(.text+0xa9): undefined reference to `_WinMain@16'
collect2: ld returned 1 exit status


...but that might not be the right way to do it anyway
The .o files mean the Makefile managed to compile all the individual source files (so all the include files are correct), but failed at the final step where it puts everything together into an executable (you didn't show any errors from there) since you mention there isn't one.

The errors you got above are because you're supposed to use g++ not gcc (if that doesn't help you might also need to add -lstdc++ afterwards), make sure you have that properly setup. In any case the Makefile should already include the full proper command.


Also if you don't mind me asking, if you're not familiar with compiling and debugging, why are you trying to compile OpenXcom yourself? There's pre-compiled Downloads freely available if you just wanna try it out.

battlesquid

  • Guest
Compiling on Cygwin
« Reply #14 on: July 05, 2010, 10:06:33 pm »
Man, compiling C++ is a lot of work... As you probably have guessed I'm actually not a C++ developer, but a Java developer. Still I'd like to be able to build the project if not to contribute anything immediately. I have tried the precompiled distribution and it runs fine :)

I was hoping this make business would come to an end soon enough, but I realize now that's probably not going to happen  :( So I understand if you don't want to spend more time helping out a beginner. It's unlikely I'd be able to contribute even something small in a long time anyway. But if there's time to help me out, I'd apprechiate it. Learning C++ with a project that's interesting for me and at the same time quite young seems appealing to me. Running g++ in stead of gcc resulted in less "undefined reference" lines. When running make now I get https://pastebin.com/Y1dFQihP which is fewer lines than last time I think. So it seems now it can't find SDL_mixer and SDL_gfx even though they are referenced at the first line as you can see. I believe I have installed those as described earlier, but apparently something is not right.