I am trying to compile main.ccp to configure my c++ project manually and have it connect to my own firebase.
#include "main.hpp"
#include <iostream>
#include "firebase/app.h"
#include "firebase/database.h"
int main()
{
firebase::AppOptions secondary_app_options;
secondary_app_options.set_api_key("API_KEY");
secondary_app_options.set_app_id("APP_ID");
secondary_app_options.set_project_id("PROJ_ID");
firebase::App* secondary_app = firebase::App::Create(secondary_app_options, "Secondary");
firebase::database::Database* secondary_database = firebase::database::Database::GetInstance(secondary_app);
return 0;
}
I use the command line to compile : g++ -std=c++11 main.cpp -o main.o
And it output:
Undefined symbols for architecture x86_64:
"firebase::App::Create(firebase::AppOptions const&, char const*)", referenced from:
_main in main-9988c0.o
"firebase::database::Database::GetInstance(firebase::App*, firebase::InitResult*)", referenced from:
_main in main-9988c0.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 did correctly download and locate all of the framework and library for firebase already. Can anybody help me with this ?
Related
I was able to setup BlockSci on macOS v10.13 (High Sierra) 10.13.6. The setup installed header files in /usr/local/include and a libblocksci.dylib in /usr/local/lib. The C++ code I am trying to compile is:
#include "blocksci.hpp"
#include <iostream>
#include <string>
int main(int argc, const char * argv[]) {
blocksci::Blockchain chain{"path/config.json"};
return 0;
};
The compile command I am using for hello.cpp is:
g++ -std=c++17 -L/usr/local/lib -I/usr/local/include/blocksci -I/usr/local/include/blocksci/external -o hello hello.cpp
However, the symbols for the BlockSci library are not found:
Undefined symbols for architecture x86_64:
"blocksci::Blockchain::Blockchain(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
_main in hello-942a60.o
"blocksci::Blockchain::~Blockchain()", referenced from:
_main in hello-942a60.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
What am I doing wrong when I try to compile this?
I found this and this that were helpful. It finally compiled with:
g++ hello.cpp -std=c++17 -I/usr/local/include/blocksci/external -o hello -L/usr/local/lib -lblocksci -Wl,-rpath,/usr/local/lib
However, now I get a runtime error:
libc++abi.dylib: terminating with uncaught exception of type std::runtime_error
Abort trap: 6
Back to the drawing board, but it compiled for now.
At first I am trying to use glad.h in my project. Xcode 7.2.1. gives me the error :
glad.h:26:2: OpenGL header already included, remove this include, glad already provides it.
These are the headers in my main.cpp :
#include "glad/glad.h"
#include <iostream>
#include "GLFW/glfw3.h"
I add GLFW_INCLUDE_NONE to packaging - preprocessor definitions and LLVM - preprocessor macros(similar to preprocessor definitions in Visual Studio I guess?). Then the errors turn to:
Undefined symbols for architecture x86_64:
"_glfwCreateWindow", referenced from:
_main in main.o
"_glfwGetPrimaryMonitor", 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)
If I remove the code #include "glad/glad.h”, the errors remain the same.
Any help is appreciated.
I have a program that i am trying to compile from my project directory and haven't been able to wrap my head around the following error
My compilation command
g++ grades.cpp -o grades
I see the following error
Undefined symbols for architecture x86_64:
"tbb::task_scheduler_init::initialize(int, unsigned long)", referenced from:
tbb::task_scheduler_init::task_scheduler_init(int, unsigned long) in grades-9c8d1a.o
"tbb::task_scheduler_init::terminate()", referenced from:
tbb::task_scheduler_init::~task_scheduler_init() in grades-9c8d1a.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 am not sure how to debug this error.
You need to link against the tbb library you are tying to use,
g++ grades.cpp -o grades -ltbb
First of all, I've read the related content on Stackoverflow on this problem but I still can't solve it. I've simplified my code as much as possible.
I've only a custom class with .h and .cpp files but I get error while trying to create an instance of this class from main.cpp.
main.cpp
#include "Customer.h"
using namespace std;
int main() {
Customer a("string");
return 0;
}
Customer.h
using namespace std;
class Customer {
public:
Customer(string input);
};
Customer.cpp
#include "Customer.h"
using namespace std;
Customer::Customer(string input) {
}
The error message I get is the following?
gcc *.cpp -o k
Undefined symbols for architecture x86_64:
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__init(char const*, unsigned long)", referenced from:
_main in main-40340f.o
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::basic_string(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
_main in main-40340f.o
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::~basic_string()", referenced from:
_main in main-40340f.o
"std::terminate()", referenced from:
___clang_call_terminate in main-40340f.o
"___cxa_begin_catch", referenced from:
___clang_call_terminate in main-40340f.o
"___gxx_personality_v0", referenced from:
_main in main-40340f.o
Dwarf Exception Unwind Info (__eh_frame) in main-40340f.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I run Mac OS X 10.9 and Sublime Text 3. gcc -v gives the following:
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.1.0
Thread model: posix
It compiles without problem when I write empty constructors instead of these.
What could cause this problem?
Two problems:
You should #include <string>.
To compile C++ code on OS X, use clang++ or g++.
Use g++ instead of gcc:
$ g++ *.cpp -o k
and then the compiler driver knows to link-in the C++ runtime library. Given it's actually clang you are using, and not gcc, then this is better:
$ clang++ *.cpp -o k
Use "g++ "instead of "gcc" to compile and link your application. It automatically knows about the C++ libraries that need to be included.
You need to install Command Line Tools.
https://developer.apple.com/downloads/
g++ main.cpp(or Customer.cpp) -o k is not enough. You should compile them at the same time.
"g++ main.cpp Customer.cpp (and other *.cpp(s) if you have) -o target "
will work well.
I am using Lear's implementation of the Gist descriptor for a project which can be found here: http://lear.inrialpes.fr/software.
I am writing an application in c++ and I want to use this library. I am having issues though with the makefile and linking in general.
These commands give me no errors:
g++ -c standalone_image.c -o standalone_image.o
g++ -c gist.c -o gist.o
However, this line
g++ compute_gist.c `pkg-config --cflags --libs opencv`
gives me the following error
Undefined symbols for architecture x86_64:
"color_gist_scaletab(color_image_t*, int, int, int const*)", referenced from:
_main in ccMFYbAU.o
"color_image_delete(color_image_t*)", referenced from:
_main in ccMFYbAU.o
"color_image_new(int, int)", referenced from:
load_ppm(char const*)in ccMFYbAU.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
I have the Mosaic c++ code in a different directory. I also tried to compile gist and standalone_image seperately, copy into the mosaic directory, and compile the Mosaic code.
Which gives me the following error:
Undefined symbols for architecture x86_64:
"color_gist_scaletab(color_image_t*, int, int, int const*)", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make: *** [mosaic] Error 1
I really want to use this library in my project, but I can't figure out a way to incorporate it in my c++.
Any help is GREATLY appreciated! Thanks!
Edit: I am using Mac Lion with:
gcc + g++ version: i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)
The lear library also uses the FFTW3 library that should work with C and C++.
The problem was that I needed the extern around the gist include, but the linking that was done in the Makefile was also wrong. It works now. :)