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
Related
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
When I compile my program that uses gtkmm I always have to add pkg-config flags to the command and the #include<gtkmm.h> is always underline red (cannot open source file).
How would I be able to get rid of the error and not have to type pkg-config gtkmm-3.0 --cflags --libs every time I compile my code, code below:
#include <gtkmm.h>
#include <iostream>
void hello_world() {
std::cout << "Hello world." << std::endl;
}
int main(int argc, char* argv[])
{
Gtk::Main app(argc, argv);
auto builder = Gtk::Builder::create_from_file("test.glade");
Gtk::Window *main_window;
builder->get_widget("window", main_window);
Gtk::Button *button1;
builder->get_widget("button1", button1);
button1->signal_clicked().connect(sigc::ptr_fun(&hello_world));
Gtk::Main::run(*main_window);
}
Without the flags I just get the error:
main.cpp:1:10: fatal error: gtkmm.h: No such file or directory
#include <gtkmm.h>
^~~~~~~~~
compilation terminated.
Have you typed in your terminal?
echo `pkg-config gtkmm-3.0 --cflags --libs`
This will display:
-pthread -I/usr/include/gtkmm-3.0 -I/usr/lib/x86_64-linux-gnu/gtkmm-3.0/include -I/usr/include/atkmm-1.6 -I/usr/include/gtk-3.0/unix-print -I/usr/include/gdkmm-3.0 -I/usr/lib/x86_64-linux-gnu/gdkmm-3.0/include -I/usr/include/giomm-2.4 -I/usr/lib/x86_64-linux-gnu/giomm-2.4/include -I/usr/include/pangomm-1.4 -I/usr/lib/x86_64-linux-gnu/pangomm-1.4/include -I/usr/include/glibmm-2.4 -I/usr/lib/x86_64-linux-gnu/glibmm-2.4/include -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0 -I/usr/include/cairo -I/usr/include/libdrm -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/cairomm-1.0 -I/usr/lib/x86_64-linux-gnu/cairomm-1.0/include -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/sigc++-2.0 -I/usr/lib/x86_64-linux-gnu/sigc++-2.0/include -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/uuid -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -lgtkmm-3.0 -latkmm-1.6 -lgdkmm-3.0 -lgiomm-2.4 -lpangomm-1.4 -lglibmm-2.4 -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lgio-2.0 -lcairomm-1.0 -lcairo -lsigc-2.0 -lgdk_pixbuf-2.0 -lgobject-2.0 -lglib-2.0
This is all your application needs to be compiled. You can type all these lines by hand but this is not a nice solution because this content depends on your environment and may change pkg-config is here to hide for you the misery.
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
This question already has answers here:
Error: undefined reference to `sqlite3_open'
(5 answers)
Closed 8 years ago.
I am running a sqlite c++ demo on Mac osx. I copied the code from the web page shown below.
reference: http://www.tutorialspoint.com/sqlite/sqlite_c_cpp.htm
The source code is
//
#include <stdio.h>
#include <stdlib.h>
#include <sqlite3.h>
#include <fstream>
#include <string>
using namespace std;
static int callback(void *NotUsed, int argc, char **argv, char **azColName){
int i;
for(i=0; i<argc; i++){
printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
}
printf("\n");
return 0;
}
int main(int argc, char* argv[])
{
sqlite3 *db;
char *zErrMsg = 0;
int rc;
char *sql;
string str;
/* Open database */
rc = sqlite3_open("test.db", &db);
if( rc ){
fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
exit(0);
}else{
fprintf(stdout, "Opened database successfully\n");
}
/* Create SQL statement */
str = "CREATE TABLE location(country text, state text, city text );CREATE TABLE weather(temp real, tempunit text);";
strcpy(sql,str.c_str());
/* Execute SQL statement */
rc = sqlite3_exec(db, sql, callback, 0, &zErrMsg);
if( rc != SQLITE_OK ){
fprintf(stderr, "SQL error: %s\n", zErrMsg);
sqlite3_free(zErrMsg);
}else{
fprintf(stdout, "Table created successfully\n");
}
sqlite3_close(db);
return 0;
}
The output is
g++ sqlite.cpp -v
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.3.0
Thread model: posix
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.9.0 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name sqlite.cpp -mrelocation-model pic -pic-level 2 -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 236.3 -v -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.1 -stdlib=libc++ -fdeprecated-macro -fdebug-compilation-dir /Users/zerocraft/KuaiPan/Course/ECEN489/test -ferror-limit 19 -fmessage-length 166 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime=macosx-10.9.0 -fencode-extended-block-signature -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -vectorize-slp -o /var/folders/1d/dbmt5pd519bcp0dqr5vv76_c0000gn/T/sqlite-742d60.o -x c++ sqlite.cpp
clang -cc1 version 5.1 based upon LLVM 3.4svn default target x86_64-apple-darwin13.3.0
ignoring nonexistent directory "/usr/include/c++/v1"
ignoring nonexistent directory "/usr/local/include"
#include "..." search starts here:
#include <...> search starts here:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.1/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
/usr/include
/System/Library/Frameworks (framework directory)
/Library/Frameworks (framework directory)
End of search list.
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.9.0 -o a.out /var/folders/1d/dbmt5pd519bcp0dqr5vv76_c0000gn/T/sqlite-742d60.o -lc++ -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.1/lib/darwin/libclang_rt.osx.a
Undefined symbols for architecture x86_64:
"_sqlite3_close", referenced from:
_main in sqlite-742d60.o
"_sqlite3_errmsg", referenced from:
_main in sqlite-742d60.o
"_sqlite3_exec", referenced from:
_main in sqlite-742d60.o
"_sqlite3_free", referenced from:
_main in sqlite-742d60.o
"_sqlite3_open", referenced from:
_main in sqlite-742d60.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 installed the sqlite library on my laptop. Can anyone cast some light on this? Thanks!
You did not link against the sqlite library. The tutorial you were following said to do this:
g++ test.c -lsqlite3
But you did this:
g++ sqlite.cpp -v
The option '-lsqlite3' tells the linker to link in the sqlite3 library. Without this, it cannot find the symbols that are defined in this library.
I'm new to open cv. At the moment I'm trying to test if I could run a simple file.
// Example showing how to read and write images
#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv/cvaux.h>
int main(int argc, char** argv)
{
IplImage * pInpImg = 0;
// Load an image from file - change this based on your image name
pInpImg = cvLoadImage("bear.jpg", CV_LOAD_IMAGE_UNCHANGED);
if(!pInpImg)
{
fprintf(stderr, "failed to load input image\n");
return -1;
}
// Write the image to a file with a different name,
// using a different image format -- .png instead of .jpg
if( !cvSaveImage("my_image_copy.png", pInpImg) )
{
fprintf(stderr, "failed to write image file\n");
}
// Remember to free image memory after using it!
cvReleaseImage(&pInpImg);
return 0;
}
I compiled it:
g++ `pkg-config –cflags opencv` cv.cpp -o cv `pkg-config –libs opencv`
I got this error:
Undefined symbols for architecture x86_64:
"_cvLoadImage", referenced from:
_main in cv-zQ5X30.o
"_cvReleaseImage", referenced from:
_main in cv-zQ5X30.o
"_cvSaveImage", referenced from:
_main in cv-zQ5X30.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'm lost here, any help would be very much appreciated.
Thank you.
i think the problem might be using "-libs" and "-cflags" instead of "--libs" and "--cflags", use this instead:
g++ `pkg-config --cflags opencv` cv.cpp -o cv `pkg-config --libs opencv`