I'm having issues getting gtkmm-4.0 to link on macOS Monterey.
I'm trying to compile this example program.
#include <gtkmm.h>
class MyWindow : public Gtk::Window {
public:
MyWindow();
};
MyWindow::MyWindow() {
set_title("Basic application");
set_default_size(200, 200);
}
int main(int argc, char* argv[]) {
auto app = Gtk::Application::create("org.gtkmm.examples.base");
return app->make_window_and_run<MyWindow>(argc, argv);
}
After trying to compile with g++-11 base.cc -o base `pkg-config gtkmm-4.0 --cflags --libs`
I get the following error:
Undefined symbols for architecture x86_64:
"__ZN3Gtk15ShortcutManager20add_controller_vfuncERKSt10shared_ptrINS_18ShortcutControllerEE", referenced from:
__ZTV8MyWindow in ccyzyk08.o
__ZTC8MyWindow0_N3Gtk6WindowE in ccyzyk08.o
__ZTC8MyWindow48_N3Gtk15ShortcutManagerE in ccyzyk08.o
"__ZN3Gtk15ShortcutManager23remove_controller_vfuncERKSt10shared_ptrINS_18ShortcutControllerEE", referenced from:
__ZTV8MyWindow in ccyzyk08.o
__ZTC8MyWindow0_N3Gtk6WindowE in ccyzyk08.o
__ZTC8MyWindow48_N3Gtk15ShortcutManagerE in ccyzyk08.o
"__ZN3Gtk6Widget14snapshot_vfuncERKSt10shared_ptrINS_8SnapshotEE", referenced from:
__ZTV8MyWindow in ccyzyk08.o
__ZTC8MyWindow0_N3Gtk6WindowE in ccyzyk08.o
__ZTC8MyWindow0_N3Gtk6WidgetE in ccyzyk08.o
"__ZN3Gtk6Widget16on_query_tooltipEiibRKSt10shared_ptrINS_7TooltipEE", referenced from:
__ZTV8MyWindow in ccyzyk08.o
__ZTC8MyWindow0_N3Gtk6WindowE in ccyzyk08.o
__ZTC8MyWindow0_N3Gtk6WidgetE in ccyzyk08.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
Does anyone know why these errors occur and how to fix them?
I'm using macOS Monterey on an Intel Mac.
I found a similar unanswered question from someone running macOS Monterey on arm64.
For reference, here is the output of `pkg-config gtkmm-4.0 --cflags --libs`:
-mfpmath=sse -msse -msse2 -I/usr/local/Cellar/libffi/3.4.2/include -I/usr/local/Cellar/gtkmm4/4.6.0/include/gtkmm-4.0 -I/usr/local/Cellar/gtkmm4/4.6.0/lib/gtkmm-4.0/include -I/usr/local/Cellar/pangomm/2.50.0/include/pangomm-2.48 -I/usr/local/Cellar/pangomm/2.50.0/lib/pangomm-2.48/include -I/usr/local/Cellar/glibmm/2.70.0/include/giomm-2.68 -I/usr/local/Cellar/glibmm/2.70.0/lib/giomm-2.68/include -I/usr/local/Cellar/glibmm/2.70.0/include/glibmm-2.68 -I/usr/local/Cellar/glibmm/2.70.0/lib/glibmm-2.68/include -I/usr/local/Cellar/cairomm/1.16.1/include/cairomm-1.16 -I/usr/local/Cellar/cairomm/1.16.1/lib/cairomm-1.16/include -I/usr/local/Cellar/libsigc++/3.2.0/include/sigc++-3.0 -I/usr/local/Cellar/libsigc++/3.2.0/lib/sigc++-3.0/include -I/usr/local/Cellar/gtk4/4.6.1/include/gtk-4.0/unix-print -I/usr/local/Cellar/gtk4/4.6.1/include/gtk-4.0 -I/usr/local/Cellar/glib/2.70.4/include/gio-unix-2.0 -I/usr/local/Cellar/libepoxy/1.5.9_1/include -I/usr/local/Cellar/cairo/1.16.0_5/include/cairo -I/usr/local/Cellar/pango/1.50.5/include/pango-1.0 -I/usr/local/Cellar/harfbuzz/4.0.1/include/harfbuzz -I/usr/local/Cellar/pango/1.50.5/include/pango-1.0 -I/usr/local/Cellar/fribidi/1.0.11/include/fribidi -I/usr/local/Cellar/harfbuzz/4.0.1/include/harfbuzz -I/usr/local/Cellar/graphite2/1.3.14/include -I/usr/local/Cellar/gdk-pixbuf/2.42.6/include/gdk-pixbuf-2.0 -I/usr/local/Cellar/libpng/1.6.37/include/libpng16 -I/usr/local/Cellar/libtiff/4.3.0/include -I/usr/local/Cellar/cairo/1.16.0_5/include/cairo -I/usr/local/Cellar/pixman/0.40.0/include/pixman-1 -I/usr/local/Cellar/fontconfig/2.13.1/include -I/usr/local/opt/freetype/include/freetype2 -I/usr/local/Cellar/libpng/1.6.37/include/libpng16 -I/usr/local/Cellar/libxcb/1.14_2/include -I/usr/local/Cellar/libxrender/0.9.10/include -I/usr/local/Cellar/libxext/1.3.4/include -I/usr/local/Cellar/libx11/1.7.3.1/include -I/usr/local/Cellar/libxcb/1.14_2/include -I/usr/local/Cellar/libxau/1.0.9/include -I/usr/local/Cellar/libxdmcp/1.1.3/include -I/usr/local/Cellar/graphene/1.10.6/include/graphene-1.0 -I/usr/local/Cellar/graphene/1.10.6/lib/graphene-1.0/include -I/usr/local/Cellar/glib/2.70.4/include -I/usr/local/Cellar/glib/2.70.4/include/glib-2.0 -I/usr/local/Cellar/glib/2.70.4/lib/glib-2.0/include -I/usr/local/opt/gettext/include -I/usr/local/Cellar/pcre/8.45/include -I/usr/local/Cellar/xorgproto/2021.5/include -L/usr/local/Cellar/gtkmm4/4.6.0/lib -L/usr/local/Cellar/pangomm/2.50.0/lib -L/usr/local/Cellar/glibmm/2.70.0/lib -L/usr/local/Cellar/cairomm/1.16.1/lib -L/usr/local/Cellar/libsigc++/3.2.0/lib -L/usr/local/Cellar/gtk4/4.6.1/lib -L/usr/local/Cellar/pango/1.50.5/lib -L/usr/local/Cellar/harfbuzz/4.0.1/lib -L/usr/local/Cellar/gdk-pixbuf/2.42.6/lib -L/usr/local/Cellar/cairo/1.16.0_5/lib -L/usr/local/Cellar/graphene/1.10.6/lib -L/usr/local/Cellar/glib/2.70.4/lib -L/usr/local/opt/gettext/lib -lgtkmm-4.0 -lpangomm-2.48 -lgiomm-2.68 -lglibmm-2.68 -lcairomm-1.16 -lsigc-3.0 -lgtk-4 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -lgdk_pixbuf-2.0 -lcairo-gobject -lcairo -lgraphene-1.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lintl
I want to verify the leveldb installation. I have a main function only containing levelDB::DB::Open() function. I installed both snappy and leveldb by using brew install. I have boost 1.67 installed too. I have GCC 8.1. I am running macOS 10.13.5.
my source file looks like this:
int main(void) {
leveldb::DB *db;
leveldb::Options options;
options.create_if_missing = true;
auto err = leveldb::DB::Open(options, "../tmpDB", &db);
if (err.ok()) {
std::cout << "success" << std::endl;
}else {
std::cout << "failed" << std::endl;
}
delete db;
return 0;
}
I compile my code I use g++ main.cpp -lleveldb -lsnappy -o test. The compiler generate the error like:
Undefined symbols for architecture x86_64:
"leveldb::DB::Open(leveldb::Options const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, leveldb::DB**)", referenced from:
_main in ccYcksfh.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
How can I solve this link error?
You can install leveldb with compiler version.
brew reinstall leveldb --cc=gcc-4.8
Can't link against leveldb on OSX
I have the following error:
Undefined symbols for architecture x86_64:
"_inflateEnd", referenced from:
uWS::Hub::~Hub() in main.o
"_inflateInit2_", referenced from:
uWS::Hub::Hub(int, bool, unsigned int) in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have checked all the similar questions and their solutions but nothing worked for me.
I am trying to test uWebSockets (https://github.com/uNetworking/uWebSockets) and have the following file structure:
my_app (which has main.cpp)
ext/uWebSockets (which is a clone of the repository above)
So, I am doing the following:
~/ext/uWebSockets$ make
make `(uname -s)`
c++ -std=c++11 -O3 -I src -shared -fPIC src/Extensions.cpp src/Group.cpp src/Networking.cpp src/Hub.cpp src/Node.cpp src/WebSocket.cpp src/HTTPSocket.cpp src/Socket.cpp src/Epoll.cpp -stdlib=libc++ -mmacosx-version-min=10.7 -undefined dynamic_lookup -L/usr/local/opt/openssl/lib -I/usr/local/opt/openssl/include -o libuWS.dylib
and obtain libuWS.dylib in /ext/uWebSockets
Then, I do the following:
~/my_app$ g++ -c main.cpp -o main.o -I../ext/uWebSockets/src -I/usr/local/opt/openssl/include -std=c++11
So now I have main.o in /my_app. But when I'm trying to:
~/my_app$ g++ -o start main.o -L../ext/uWebSockets -luWS
I receive the aforementioned error:
Undefined symbols for architecture x86_64:
"_inflateEnd", referenced from:
uWS::Hub::~Hub() in main.o
"_inflateInit2_", referenced from:
uWS::Hub::Hub(int, bool, unsigned int) in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Here is the same command with -v:
~/my_app$ g++ -o start main.o -L../ext/uWebSockets -luWS -v
Apple LLVM version 9.0.0 (clang-900.0.39.2)
Target: x86_64-apple-darwin17.3.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
"/Library/Developer/CommandLineTools/usr/bin/ld" -demangle -lto_library /Library/Developer/CommandLineTools/usr/lib/libLTO.dylib -dynamic -arch x86_64 -macosx_version_min 10.13.0 -o start -L../ext/uWebSockets main.o -luWS -lc++ -lSystem /Library/Developer/CommandLineTools/usr/lib/clang/9.0.0/lib/darwin/libclang_rt.osx.a
Undefined symbols for architecture x86_64:
"_inflateEnd", referenced from:
uWS::Hub::~Hub() in main.o
"_inflateInit2_", referenced from:
uWS::Hub::Hub(int, bool, unsigned int) in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
How can I link them correctly?
main.cpp:
#include <iostream>
#include "uWS.h"
int main() {
uWS::Hub h;
h.onError([](void *user) {
std::cout << "WebSocket: Error has occured" << std::endl;
});
h.onConnection([](uWS::WebSocket<uWS::CLIENT> *ws, uWS::HttpRequest req) {
std::cout << "Client established a remote connection over non-SSL" << std::endl;
});
h.onDisconnection([](uWS::WebSocket<uWS::CLIENT> *ws, int code, char *message, size_t length) {
std::cout << "Client got disconnected with data: " << ws->getUserData() << ", code: " << code << ", message: <" << std::string(message, length) << ">" << std::endl;
});
// url, user, headers, timeout, group client
h.connect("wss://www.test.com/", (void *) 0, {}, 5000);
h.run();
std::cout << "Falling through testConnections" << std::endl;
return 0;
}
Finally, I was able to fix it. The problem was in zlib, which I didn't include.
So the correct way of running this is g++ -o start main.o -luWS -lz
My program is this Sierpinski Gasket. I'm using Netbeans on my MacBook Pro and I believe I have the libraries installed but maybe they are not linked correctly.
#include <iostream>
#include <stdio.h>
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <GLUT/glut.h>
#include <OpenGL/glext.h>
void myinit(){
glClearColor(1.0,1.0,1.0,1.0);
glColor3f(1.0,0.0,0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0,50.0,0.0,50.0);
glMatrixMode(GL_MODELVIEW);
}
void display(){
GLfloat vertices[3][2]={{0.0,0.0},{25.0,50.0},{50.0,0.0}};
int i, j, k;
int rand();
GLfloat p[2]={7.5,5.0};
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POINTS);
for(k=0; k<5000; k++){
j=rand()*3;
p[0]=(p[0]+vertices[j][0])/2.0;
p[1]=(p[1]+vertices[j][1])/2.0;
glVertex2fv(p);
}
glEnd();
glFlush();
}
int main(int argc, char** argv) {
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(500,500);
glutInitWindowPosition(0,0);
glutCreateWindow("Sierpinski Gasket");
glutDisplayFunc(display);
myinit();
glutMainLoop();
}
Here are the compilation errors:
Undefined symbols for architecture x86_64:
"_glutInit", referenced from:
_main in main.o
"_glutInitDisplayMode", referenced from:
_main in main.o
"_glutInitWindowSize", referenced from:
_main in main.o
"_glutInitWindowPosition", referenced from:
_main in main.o
"_glutCreateWindow", referenced from:
_main in main.o
"_glutDisplayFunc", referenced from:
_main in main.o
"_glutMainLoop", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make[2]: *** [dist/Debug/GNU-MacOSX/sierpinski] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
You need to link the GLUT framework. In Project Properties > Linker > Command Line > Aditional Options, specify
-framework GLUT
Slight correction in your code:
j = rand() % 3;
and not rand() * 3;. That gives seg fault for obvious reasons.
To complement #user55721's GLUT framework answer, in the context of installing JasPer.
The INSTALL doc mentions an arch specific cmake option to use native GLUT on Mac OS:
When building the JasPer software under Mac OSX, only the use of the
native framework for OpenGL is officially supported. If the Freeglut
library is installed on your system, you will need to ensure that the
native GLUT library (as opposed to the Freeglut library) is used by
the build process. This can be accomplished by adding an extra option
to the cmake command line that resembles the following:
-DGLUT_glut_LIBRARY=/System/Library/Frameworks/GLUT.framework
I'm just trying to compile the linux-based FCEUX (NES emulator) on my mac, OS X 10.5 Leopard.
I got all the dependencies (SDL, GTK+ 2) going and everything but of all things this is now my problem:
Undefined symbols:
"_compress", referenced from: SaveSnapshot() in video.o
"_gzclose", referenced from: FCEU_fopen(char const*, char const*, char*, char*, int, char const**)in file.o
"_crc32", referenced from: CalcCRC32(unsigned int, unsigned char*, unsigned int)in crc32.o
_unzReadCurrentFile in unzip.o _unzReadCurrentFile in unzip.o
"_uncompress", referenced from: NetplayUpdate(unsigned char*)in netplay.o FCEUSS_LoadFP(EMUFILE*, ENUM_SSLOADPARAMS) in state.o
"_compress2", referenced from: FCEUNET_SendFile(unsigned char, char*)in netplay.o FCEUSS_SaveMS(EMUFILE*, int) in state.o
"_inflateEnd", referenced from: _unzCloseCurrentFile in unzip.o
"_inflate", referenced from: _unzReadCurrentFile in unzip.o
"inflateInit2", referenced from: _unzOpenCurrentFile in unzip.o
"_gzgetc", referenced from: FCEU_fopen(char const*, char const*, char*, char*, int, char const**)in file.o
"_gzopen", referenced from: FCEU_fopen(char const*, char const*, char*, char*, int, char const**)in file.o
"_gzread", referenced from: FCEU_fopen(char const*, char const*, char*, char*, int, char const**)in file.o
"_gzseek", referenced from: FCEU_fopen(char const*, char const*, char*, char*, int, char const*)in file.o
ld: symbol(s) not found collect2: ld returned 1 exit status
scons: ** [src/fceux] Error 1 scons: building terminated because of errors.
Those are zlib functions. It seems like it is loading the zlib.h ok, but the symbols aren't being linked in? Just to make sure I downloaded the latest zlib and did a make install, no help. I have no clue what's going on here, it seems like it should be pretty basic, that library is nothing special. Help would be appreciated. Thanks.
EDIT: Here is the link list:
scons: done reading SConscript files.
scons: Building targets ...
g++ -o src/fceux -Wl,-framework,Cocoa src/asm.o src/cart.o src/cheat.o src/conddebug.o src/config.o src/debug.o src/drawing.o src/emufile.o src/fceu.o src/fds.o src/file.o src/filter.o src/ines.o src/input.o src/netplay.o src/nsf.o src/oldmovie.o src/palette.o src/ppu.o src/sound.o src/state.o src/unif.o src/video.o src/vsuni.o src/wave.o src/x6502.o src/movie.o src/lua-engine.o src/boards/01-222.o src/boards/103.o src/boards/106.o src/boards/108.o src/boards/112.o src/boards/117.o src/boards/120.o src/boards/121.o src/boards/15.o src/boards/164.o src/boards/175.o src/boards/176.o src/boards/177.o src/boards/178.o src/boards/179.o src/boards/183.o src/boards/185.o src/boards/186.o src/boards/187.o src/boards/189.o src/boards/199.o src/boards/208.o src/boards/222.o src/boards/23.o src/boards/235.o src/boards/253.o src/boards/3d-block.o src/boards/411120-c.o src/boards/43.o src/boards/57.o src/boards/603-5052.o src/boards/68.o src/boards/8157.o src/boards/8237.o src/boards/830118C.o src/boards/88.o src/boards/90.o src/boards/95.o src/boards/a9711.o src/boards/a9746.o src/boards/addrlatch.o src/boards/ax5705.o src/boards/bandai.o src/boards/bmc13in1jy110.o src/boards/bmc42in1r.o src/boards/bmc64in1nr.o src/boards/bmc70in1.o src/boards/bonza.o src/boards/bs-5.o src/boards/copyfami_mmc3.o src/boards/dance.o src/boards/datalatch.o src/boards/deirom.o src/boards/dream.o src/boards/__dummy_mapper.o src/boards/edu2000.o src/boards/fk23c.o src/boards/ghostbusters63in1.o src/boards/gs-2004.o src/boards/gs-2013.o src/boards/h2288.o src/boards/karaoke.o src/boards/kof97.o src/boards/konami-qtai.o src/boards/ks7032.o src/boards/malee.o src/boards/mmc1.o src/boards/mmc3.o src/boards/mmc5.o src/boards/n-c22m.o src/boards/n106.o src/boards/n625092.o src/boards/novel.o src/boards/sachen.o src/boards/sc-127.o src/boards/sheroes.o src/boards/sl1632.o src/boards/smb2j.o src/boards/subor.o src/boards/super24.o src/boards/supervision.o src/boards/t-227-1.o src/boards/t-262.o src/boards/tengen.o src/boards/tf-1201.o src/drivers/common/args.o src/drivers/common/cheat.o src/drivers/common/config.o src/drivers/common/hq2x.o src/drivers/common/hq3x.o src/drivers/common/scale2x.o src/drivers/common/scale3x.o src/drivers/common/scalebit.o src/drivers/common/vidblit.o src/drivers/common/configSys.o src/drivers/common/nes_ntsc.o src/input/arkanoid.o src/input/bworld.o src/input/cursor.o src/input/fkb.o src/input/ftrainer.o src/input/hypershot.o src/input/mahjong.o src/input/mouse.o src/input/oekakids.o src/input/powerpad.o src/input/quiz.o src/input/shadow.o src/input/suborkb.o src/input/toprider.o src/input/zapper.o src/utils/crc32.o src/utils/endian.o src/utils/general.o src/utils/guid.o src/utils/md5.o src/utils/memory.o src/utils/unzip.o src/utils/xstring.o src/mappers/151.o src/mappers/16.o src/mappers/17.o src/mappers/18.o src/mappers/193.o src/mappers/201.o src/mappers/202.o src/mappers/203.o src/mappers/204.o src/mappers/212.o src/mappers/213.o src/mappers/214.o src/mappers/215.o src/mappers/217.o src/mappers/21.o src/mappers/225.o src/mappers/227.o src/mappers/228.o src/mappers/229.o src/mappers/22.o src/mappers/230.o src/mappers/231.o src/mappers/232.o src/mappers/234.o src/mappers/241.o src/mappers/242.o src/mappers/244.o src/mappers/246.o src/mappers/24and26.o src/mappers/255.o src/mappers/25.o src/mappers/27.o src/mappers/32.o src/mappers/33.o src/mappers/40.o src/mappers/41.o src/mappers/42.o src/mappers/46.o src/mappers/50.o src/mappers/51.o src/mappers/59.o src/mappers/60.o src/mappers/61.o src/mappers/62.o src/mappers/65.o src/mappers/67.o src/mappers/69.o src/mappers/6.o src/mappers/71.o src/mappers/72.o src/mappers/73.o src/mappers/75.o src/mappers/76.o src/mappers/77.o src/mappers/79.o src/mappers/80.o src/mappers/82.o src/mappers/83.o src/mappers/85.o src/mappers/86.o src/mappers/89.o src/mappers/8.o src/mappers/91.o src/mappers/92.o src/mappers/97.o src/mappers/99.o src/mappers/emu2413.o src/mappers/mmc2and4.o src/mappers/simple.o src/lua/src/lapi.o src/lua/src/lauxlib.o src/lua/src/lbaselib.o src/lua/src/lcode.o src/lua/src/ldblib.o src/lua/src/ldebug.o src/lua/src/ldo.o src/lua/src/ldump.o src/lua/src/lfunc.o src/lua/src/lgc.o src/lua/src/linit.o src/lua/src/liolib.o src/lua/src/llex.o src/lua/src/lmathlib.o src/lua/src/lmem.o src/lua/src/loadlib.o src/lua/src/lobject.o src/lua/src/lopcodes.o src/lua/src/loslib.o src/lua/src/lparser.o src/lua/src/lstate.o src/lua/src/lstring.o src/lua/src/lstrlib.o src/lua/src/ltable.o src/lua/src/ltablib.o src/lua/src/ltm.o src/lua/src/lundump.o src/lua/src/lvm.o src/lua/src/lzio.o src/lua/src/print.o src/drivers/sdl/input.o src/drivers/sdl/config.o src/drivers/sdl/sdl.o src/drivers/sdl/sdl-joystick.o src/drivers/sdl/sdl-sound.o src/drivers/sdl/sdl-throttle.o src/drivers/sdl/sdl-video.o src/drivers/sdl/unix-netplay.o
-L/usr/local/lib
-lgtk-quartz-2.0
-lgdk-quartz-2.0
-latk-1.0
-lgio-2.0
-lgdk_pixbuf-2.0
-lpangocairo-1.0
-lpango-1.0
-lcairo
-lgobject-2.0
-lgmodule-2.0
-lgthread-2.0
-lglib-2.0
-lintl
-lSDLmain
-lSDL
SConstruct file:
import os
import sys
import platform
opts = Variables()
opts.AddVariables(
BoolVariable('FRAMESKIP', 'Enable frameskipping', 1),
BoolVariable('OPENGL', 'Enable OpenGL support', 1),
BoolVariable('LSB_FIRST', 'Least signficant byte first (non-PPC)', 1),
BoolVariable('DEBUG', 'Build with debugging symbols', 1),
BoolVariable('LUA', 'Enable Lua support', 1),
BoolVariable('NEWPPU', 'Enable new PPU core', 1),
BoolVariable('CREATE_AVI', 'Enable avi creation support (SDL only)', 0),
BoolVariable('LOGO', 'Enable a logoscreen when creating avis (SDL only)', '1'),
BoolVariable('GTK', 'Enable GTK2 GUI (SDL only)', 1),
BoolVariable('GTK_LITE', 'Enable GTK2 for dialogs only', 0)
)
env = Environment(options = opts)
# LSB_FIRST must be off for PPC to compile
if platform.system == "ppc":
env['LSB_FIRST'] = 0
# Default compiler flags:
env.Append(CCFLAGS = ['-Wall', '-Wno-write-strings', '-Wno-sign-compare', '-O2', '-Isrc/lua/src'])
if os.environ.has_key('PLATFORM'):
env.Replace(PLATFORM = os.environ['PLATFORM'])
if os.environ.has_key('CC'):
env.Replace(CC = os.environ['CC'])
if os.environ.has_key('CXX'):
env.Replace(CXX = os.environ['CXX'])
if os.environ.has_key('WINDRES'):
env.Replace(WINDRES = os.environ['WINDRES'])
if os.environ.has_key('CFLAGS'):
env.Append(CCFLAGS = os.environ['CFLAGS'].split())
if os.environ.has_key('LDFLAGS'):
env.Append(LINKFLAGS = os.environ['LDFLAGS'].split())
print "platform: ", env['PLATFORM']
# special flags for cygwin
# we have to do this here so that the function and lib checks will go through mingw
if env['PLATFORM'] == 'cygwin':
env.Append(CCFLAGS = " -mno-cygwin")
env.Append(LINKFLAGS = " -mno-cygwin")
env['LIBS'] = ['wsock32'];
if env['PLATFORM'] == 'win32':
env.Append(CPPPATH = [".", "drivers/win/", "drivers/common/", "drivers/", "drivers/win/zlib", "drivers/win/directx", "drivers/win/lua/include"])
env.Append(CPPDEFINES = ["PSS_STYLE=2", "WIN32", "_USE_SHARED_MEMORY_", "NETWORK", "FCEUDEF_DEBUGGER", "NOMINMAX", "NEED_MINGW_HACKS", "_WIN32_IE=0x0600"])
env.Append(LIBS = ["rpcrt4", "comctl32", "vfw32", "winmm", "ws2_32", "comdlg32", "ole32", "gdi32", "htmlhelp"])
else:
conf = Configure(env)
if not conf.CheckLib('SDL'):
print 'Did not find libSDL or SDL.lib, exiting!'
Exit(1)
if env['GTK'] or env['GTK_LITE']:
# Add compiler and linker flags from pkg-config
env.ParseConfig('pkg-config --cflags --libs gtk+-2.0')
env.Append(CPPDEFINES=["_GTK2"])
if env['GTK']:
env.Append(CCFLAGS = ["-D_GTK"])
env.Append(CCFLAGS =["-D_GTK_LITE"])
if env['GTK_LITE']:
env.Append(CCFLAGS =["-D_GTK_LITE"])
### Lua platform defines
### Applies to all files even though only lua needs it, but should be ok
if env['LUA']:
if env['PLATFORM'] == 'darwin':
# Define LUA_USE_MACOSX otherwise we can't bind external libs from lua
env.Append(CCFLAGS = ["-DLUA_USE_MACOSX"])
if env['PLATFORM'] == 'posix':
# If we're POSIX, we use LUA_USE_LINUX since that combines usual lua posix defines with dlfcn calls for dynamic library loading.
# Should work on any *nix
env.Append(CCFLAGS = ["-DLUA_USE_LINUX"])
### Search for gd if we're not in Windows
if env['PLATFORM'] != 'win32' and env['PLATFORM'] != 'cygwin' and env['CREATE_AVI'] and env['LOGO']:
gd = conf.CheckLib('gd', autoadd=1)
if gd == 0:
env['LOGO'] = 0
print 'Did not find libgd, you won\'t be able to create a logo screen for your avis.'
if conf.CheckFunc('asprintf'):
conf.env.Append(CCFLAGS = "-DHAVE_ASPRINTF")
if env['OPENGL'] and conf.CheckLibWithHeader('GL', 'GL/gl.h', 'c++', autoadd=1):
conf.env.Append(CCFLAGS = "-DOPENGL")
conf.env.Append(CPPDEFINES = ['PSS_STYLE=1'])
# parse SDL cflags/libs
env.ParseConfig('sdl-config --cflags --libs')
env.Append(CPPDEFINES=["_S9XLUA_H"])
env = conf.Finish()
if sys.byteorder == 'little' or env['PLATFORM'] == 'win32':
env.Append(CPPDEFINES = ['LSB_FIRST'])
if env['FRAMESKIP']:
env.Append(CPPDEFINES = ['FRAMESKIP'])
print "base CPPDEFINES:",env['CPPDEFINES']
print "base CCFLAGS:",env['CCFLAGS']
if env['DEBUG']:
env.Append(CPPDEFINES=["_DEBUG"], CCFLAGS = ['-g'])
if env['PLATFORM'] != 'win32' and env['PLATFORM'] != 'cygwin' and env['CREATE_AVI']:
env.Append(CPPDEFINES=["CREATE_AVI"])
else:
env['CREATE_AVI']=0;
Export('env')
SConscript('src/SConscript')
# Install rules
exe_suffix = ''
if env['PLATFORM'] == 'win32':
exe_suffix = '.exe'
fceux_src = 'src/fceux' + exe_suffix
fceux_dst = 'bin/fceux' + exe_suffix
auxlib_src = 'src/auxlib.lua'
auxlib_dst = 'bin/auxlib.lua'
fceux_h_src = 'src/drivers/win/help/fceux.chm'
fceux_h_dst = 'bin/fceux.chm'
env.Command(fceux_h_dst, fceux_h_src, [Copy(fceux_h_dst, fceux_h_src)])
env.Command(fceux_dst, fceux_src, [Copy(fceux_dst, fceux_src)])
env.Command(auxlib_dst, auxlib_src, [Copy(auxlib_dst, auxlib_src)])
# TODO: Fix this build script to gracefully install auxlib and the man page
#env.Alias(target="install", source=env.Install(dir="/usr/local/bin/", source=("bin/fceux", "bin/auxlib.lua")))
env.Alias(target="install", source=env.Install(dir="/usr/local/bin/", source="bin/fceux"))
I dug into scons to find my answer.
I added this to the SConstruct file (in one of the non-win32 sections):
env['LIBS'] = ['z']
Think this would be worth mentioning to the FCE team or is this something that typically isn't a problem on linux machines?