Trying to compile a linux-based app on Mac OS X - c++
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?
Related
gtkmm-4.0 will not link on macOS Monterey
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
Integrating Crashpad with MacOS Qt application
Our Qt application is built using qmake. We've built Crashpad from this commit which is currently the tip of master. We've linked our Qt application with libclient.a, libbase.a, libhandler.a, libutil.a, Security.Framework and AppKit.Framework and have added the relevant include directories. When we build our application we get the following errors from the linker: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -stdlib=libc++ -headerpad_max_install_names -arch x86_64 -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -mmacosx-version-min=10.13 -Wl,-rpath,#executable_path/../Frameworks -Wl,-rpath,/Users/bobby/Qt/5.14.2/clang_64/lib -o myQtCrasher.app/Contents/MacOS/myQtCrasher main.o mainwindow.o qrc_myQtCrasher.o moc_mainwindow.o -F/Users/bobby/Qt/5.14.2/clang_64/lib -framework Security -L/Users/bobby/Documents/Qt/myQtCrasher/../../../Desktop/bugsplat/crashpad/crashpad/out/Default/obj/client/ -lclient -L/Users/bobby/Documents/Qt/myQtCrasher/../../../Desktop/bugsplat/crashpad/crashpad/out/Default/obj/handler/ -lhandler -L/Users/bobby/Documents/Qt/myQtCrasher/../../../Desktop/bugsplat/crashpad/crashpad/out/Default/obj/minidump/ -lformat -lminidump -L/Users/bobby/Documents/Qt/myQtCrasher/../../../Desktop/bugsplat/crashpad/crashpad/out/Default/obj/snapshot/ -lcontext -lsnapshot -L/Users/bobby/Documents/Qt/myQtCrasher/../../../Desktop/bugsplat/crashpad/crashpad/out/Default/obj/third_party/mini_chromium/mini_chromium/base/ -lbase -L/Users/bobby/Documents/Qt/myQtCrasher/../../../Desktop/bugsplat/crashpad/crashpad/out/Default/obj/util/ -lutil -framework QtWidgets -framework QtGui -framework AppKit -framework Metal -framework QtCore -framework DiskArbitration -framework IOKit -framework OpenGL -framework AGL Undefined symbols for architecture x86_64: "___MIG_check__Request__child_port_check_in_t", referenced from: crashpad::ChildPortServer::MachMessageServerFunction(mach_msg_header_t const*, mach_msg_header_t*, bool*) in libutil.a(util.child_port_server.o) "___MIG_check__Request__mach_notify_dead_name_t", referenced from: crashpad::NotifyServer::MachMessageServerFunction(mach_msg_header_t const*, mach_msg_header_t*, bool*) in libutil.a(util.notify_server.o) "___MIG_check__Request__mach_notify_no_senders_t", referenced from: crashpad::NotifyServer::MachMessageServerFunction(mach_msg_header_t const*, mach_msg_header_t*, bool*) in libutil.a(util.notify_server.o) "___MIG_check__Request__mach_notify_port_deleted_t", referenced from: crashpad::NotifyServer::MachMessageServerFunction(mach_msg_header_t const*, mach_msg_header_t*, bool*) in libutil.a(util.notify_server.o) "___MIG_check__Request__mach_notify_port_destroyed_t", referenced from: crashpad::NotifyServer::MachMessageServerFunction(mach_msg_header_t const*, mach_msg_header_t*, bool*) in libutil.a(util.notify_server.o) "___MIG_check__Request__mach_notify_send_once_t", referenced from: crashpad::NotifyServer::MachMessageServerFunction(mach_msg_header_t const*, mach_msg_header_t*, bool*) in libutil.a(util.notify_server.o) "_audit_token_to_pid", referenced from: crashpad::AuditPIDFromMachMessageTrailer(mach_msg_trailer_t const*) in libutil.a(util.mach_message.o) "_child_port_check_in", referenced from: crashpad::ChildPortHandshake::RunClientInternal_SendCheckIn(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned long long, unsigned int, unsigned int) in libutil.a(util.child_port_handshake.o) ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [myQtCrasher.app/Contents/MacOS/myQtCrasher] Error 1 11:18:12: The process "/usr/bin/make" exited with code 2. Error while building/deploying project myQtCrasher (kit: Desktop Qt 5.14.2 clang 64bit) When executing step "Make" 11:18:12: Elapsed time: 00:02. When we investigated child_port_server.o (using nm) we found that the symbol ___MIG_check__Request__child_port_check_in_t was undefined. This lead us back to out/Default/gen/util/mach/child_port_server.c where we found the following: #if !defined(__MigTypeCheck) && defined(TypeCheck) #define __MigTypeCheck TypeCheck /* Legacy setting */ #endif /* !defined(__MigTypeCheck) */ ... #if ( __MigTypeCheck ) #if __MIG_check__Request__child_port_subsystem__ #if !defined(__MIG_check__Request__child_port_check_in_t__defined) #define __MIG_check__Request__child_port_check_in_t__defined mig_external kern_return_t __MIG_check__Request__child_port_check_in_t(__attribute__((__unused__)) __Request__child_port_check_in_t *In0P) { typedef __Request__child_port_check_in_t __Request; #if __MigTypeCheck if (!(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || (In0P->msgh_body.msgh_descriptor_count != 1) || (In0P->Head.msgh_size != (mach_msg_size_t)sizeof(__Request))) return MIG_BAD_ARGUMENTS; #endif /* __MigTypeCheck */ #if __MigTypeCheck if (In0P->port.type != MACH_MSG_PORT_DESCRIPTOR) return MIG_TYPE_ERROR; #endif /* __MigTypeCheck */ return MACH_MSG_SUCCESS; } #endif /* !defined(__MIG_check__Request__child_port_check_in_t__defined) */ #endif /* __MIG_check__Request__child_port_subsystem__ */ #endif /* ( __MigTypeCheck ) */ With limited knowledge of the gen and ninja we attempted to pass the -DTypeCheck flag by modifying util.ninja but this broke compilation. We're stuck and we would appreciate any help the community is willing to provide! How do we fix the remainder of our linker errors?
We were able to solve this thanks to a response to our post in Crashpad-dev Add libbsm to your .pro file macx: LIBS += -lbsm Add all the .o files in out/Default/obj/out/Default/gen/util/mach to your .pro file macx: LIBS += /path/to/crashpad/crashpad/out/Default/obj/out/Default/gen/util/mach/mig_output.child_portServer.o macx: LIBS += /path/to/crashpad/crashpad/out/Default/obj/out/Default/gen/util/mach/mig_output.child_portUser.o macx: LIBS += /path/to/crashpad/crashpad/out/Default/obj/out/Default/gen/util/mach/mig_output.excServer.o macx: LIBS += /path/to/crashpad/crashpad/out/Default/obj/out/Default/gen/util/mach/mig_output.excUser.o macx: LIBS += /path/to/crashpad/crashpad/out/Default/obj/out/Default/gen/util/mach/mig_output.mach_excServer.o macx: LIBS += /path/to/crashpad/crashpad/out/Default/obj/out/Default/gen/util/mach/mig_output.mach_excUser.o macx: LIBS += /path/to/crashpad/crashpad/out/Default/obj/out/Default/gen/util/mach/mig_output.notifyServer.o macx: LIBS += /path/to/crashpad/crashpad/out/Default/obj/out/Default/gen/util/mach/mig_output.notifyUser.o
leveled::DB::Open() undefined after I installed leveldb and snappy, macOS
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
Xcode gives Mach-O linker error: "_JNI_CreateJavaVM", referenced from: _main in main.o
I get this error from testing JNI: Undefined symbols for architecture x86_64: "_JNI_CreateJavaVM", referenced from: _main 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 c++ code: #include <jni.h> #include <iostream> using namespace std; int main() { int res; JavaVMInitArgs vm_args; JavaVMOption options[3]; JavaVM *jvm; JNIEnv *env; jmethodID mid; options[0].optionString = "-Djava.compiler=NONE"; options[1].optionString = "-Djava.class.path = /Users/stephen/course/test/Test"; options[2].optionString = "-verbose:NONE"; vm_args.version = JNI_VERSION_1_8; vm_args.nOptions = 3; vm_args.options = options; vm_args.ignoreUnrecognized = JNI_TRUE; res = JNI_CreateJavaVM(&jvm,(void**)&env,&vm_args); if(res == JNI_ERR){ cout << "Error invoking the JVM"; return 1; } cout <<"create JVM successfully!"<<endl; jclass cls = env->FindClass("/Users/stephen/course/Qt-project/test/Test"); if(cls != 0){ cout<<"find class successfully!" << endl; } mid = env->GetMethodID(cls,"sayHello","stephen"); if(mid != 0){ cout<<"Invoke method successfully!" << endl; } jvm->DestroyJavaVM(); return 0; } Here is java code: public class Test { public static void sayHello(String s){ System.out.print("hello I am" + s + "\n"); } } I add the include path of " jdk/include; jdk/include/darwin" the project, also I add lib path of " jdk/jre/lib/server" to the project to get the libjvm.dylib. The c++ standard library of my project is libstdc++(gnu c++ standard library. But I can't solve this problem as expected.
Take a look here for a sample code where JVM library is linked with your project: https://github.com/mkowsiak/jnicookbook/tree/master/recipes/recipeNo028 Take a look at Makefile. Especially, here: main: recipeNo028_main.o ld -o lib/recipeNo028_main -L${JAVA_HOME}/jre/lib/server/ \ -ljvm \ $(MAC_OS_FLAGS) \ lib/recipeNo028_main.o where jvm lib is linked with the code, and here: CC=llvm-gcc MAC_OS_FLAGS=-rpath ${JAVA_HOME}/jre/lib/server -L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -demangle -dynamic -arch x86_64 -macosx_version_min 10.12.0 -lSystem where all required libs are added to your code as well. It should work. Try to compile sample code. You can find more samples here: http://jnicookbook.owsiak.org Update How to use arbitrary JDK version for compilation. First, take a look at all installations you have /usr/libexec/java_home -V This will produce something like this /usr/libexec/java_home -V Matching Java Virtual Machines (4): 9, x86_64: "Java SE 9" /Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home 1.8.0_144, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home 1.8.0_111, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home 1.7.0_80, x86_64: "Java SE 7" /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home Then, before running make, simply set JAVA_HOME to whatever you like export JAVA_HOME=$(/usr/libexec/java_home -v 9) Now, your code will use version that you have chosen.
First leveldb c++ sample code failed to link: what's the error indicating and how to fix it?
I've just installed level db on my mac with brew install leveldb, and I've got this sample code: #include <assert.h> #include <string.h> #include <leveldb/db.h> #include <iostream> int main(){ leveldb::DB* db; leveldb::Options options; options.create_if_missing = true; leveldb::Status status = leveldb::DB::Open(options,"/tmp/testdb", &db); assert(status.ok()); //write key1,value1 std::string key="key"; std::string value = "value"; status = db->Put(leveldb::WriteOptions(), key,value); assert(status.ok()); status = db->Get(leveldb::ReadOptions(), key, &value); assert(status.ok()); std::cout<<value<<std::endl; std::string key2 = "key2"; //move the value under key to key2 status = db->Put(leveldb::WriteOptions(),key2,value); assert(status.ok()); status = db->Delete(leveldb::WriteOptions(), key); assert(status.ok()); status = db->Get(leveldb::ReadOptions(),key2, &value); assert(status.ok()); std::cout<<key2<<"==="<<value<<std::endl; status = db->Get(leveldb::ReadOptions(),key, &value); if(!status.ok()) std::cerr<<key<<" "<<status.ToString()<<std::endl; else std::cout<<key<<"==="<<value<<std::endl; delete db; return 0; } I tried to compile and link it: $ ls /usr/local/lib/libleveldb.a /usr/local/lib/libleveldb.a $ clang++ -o test test.cpp /usr/local/lib/libleveldb.a -lpthread -Iinclude Undefined symbols for architecture x86_64: "snappy::RawCompress(char const*, unsigned long, char*, unsigned long*)", referenced from: leveldb::TableBuilder::WriteBlock(leveldb::BlockBuilder*, leveldb::BlockHandle*) in libleveldb.a(table_builder.o) "snappy::RawUncompress(char const*, unsigned long, char*)", referenced from: leveldb::ReadBlock(leveldb::RandomAccessFile*, leveldb::ReadOptions const&, leveldb::BlockHandle const&, leveldb::BlockContents*) in libleveldb.a(format.o) "snappy::MaxCompressedLength(unsigned long)", referenced from: leveldb::TableBuilder::WriteBlock(leveldb::BlockBuilder*, leveldb::BlockHandle*) in libleveldb.a(table_builder.o) "snappy::GetUncompressedLength(char const*, unsigned long, unsigned long*)", referenced from: leveldb::ReadBlock(leveldb::RandomAccessFile*, leveldb::ReadOptions const&, leveldb::BlockHandle const&, leveldb::BlockContents*) in libleveldb.a(format.o) ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) Is there anything wrong with my installation and compilation?
It looks like you also need to be linking snappy. I assume this is because leveldb is also using that library. So you'll want to download that an install it as either a static or shared library and link it using -lsnappy. Make sure you place the linker flag to snappy after the linker flag for leveldb so it can fill in the symbols that leveldb is missing.