So I have been writing a c++ program and in it it handles integers too large for the inbuilt long long. No problem, I'll just use a bignum library. So I get GMP, utter those three magic commands "./configure, make, make install" and start using it. I use #include "gmpxx.h" as specified in the docs for a c++ program. Compiling it, GPP finds an error in gmpxx.h as apparently gmp.h can't be located using angles and quotes should be used instead in the include statement in gmpxx.h. Upon changing the angles to quotes, however, I am surprised to discover that something has gone wrong, I think with 'make'. It says:
Undefined symbols for architecture x86_64:
"___gmpz_clear", referenced from:
__gmp_expr<__mpz_struct [1], __mpz_struct [1]>::~__gmp_expr() in primality-3fd487.o
"___gmpz_cmp_si", referenced from:
__gmp_binary_equal::eval(__mpz_struct const*, long) in primality-3fd487.o
"___gmpz_init", referenced from:
__gmp_expr<__mpz_struct [1], __mpz_struct [1]>::__gmp_expr() in primality-3fd487.o
"___gmpz_set_d", referenced from:
__gmp_expr<__mpz_struct [1], __mpz_struct [1]>::assign_d(double) in primality-3fd487.o
"___gmpz_tdiv_r_ui", referenced from:
__gmp_binary_modulus::eval(__mpz_struct*, __mpz_struct const*, long) in primality-3fd487.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Does anyone know how to stop either of these errors occurring?
Related
so I've been trying to install OpenCV with C++ on my mac using this tutorial: https://medium.com/#jaskaranvirdi/setting-up-opencv-and-c-development-environment-in-xcode-b6027728003 but I keep getting this error on Xcode:
" 'opencv2/core.hpp' file not found "
I tried setting both Library Search Paths and Header Search Paths to recursive but it didn't change anything
I've also been getting this error on the terminal, I don't know if it's related. I think it's important to note that this isn't my first time trying to install opencv and I don't know if it's the old versions that keep messing with it. I tried to cleanup everything before installing this version but I'm not sure.
Undefined symbols for architecture x86_64:
"cv::namedWindow(cv::String const&, int)", referenced from:
_main in main-55ed98.o
"cv::String::deallocate()", referenced from:
cv::String::~String() in main-55ed98.o
cv::String::operator=(cv::String const&) in main-55ed98.o
"cv::String::allocate(unsigned long)", referenced from:
cv::String::String(char const*) in main-55ed98.o
"cv::imshow(cv::String const&, cv::_InputArray const&)", referenced from:
_main in main-55ed98.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Any suggestions on how to solve these issues please?
$clang++ main.cpp -o out
Got following error, the same error happens when changing to g++. I have tested on some simple simple c++ code, the command works fine. So it the problem in that PNG class file? However, the same files worked on my MacOS before, but suddenly failed today.
Undefined symbols for architecture x86_64:
"PNG::writeToFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
_main in main-f6a06a.o
"PNG::PNG(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
_main in main-f6a06a.o
"PNG::PNG(unsigned long, unsigned long)", referenced from:
_main in main-f6a06a.o
"PNG::~PNG()", referenced from:
_main in main-f6a06a.o
"PNG::operator()(unsigned long, unsigned long)", referenced from:
_main in main-f6a06a.o
"PNG::width() const", referenced from:
_main in main-f6a06a.o
"PNG::height() const", referenced from:
_main in main-f6a06a.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Did you miss providing static/shared to the linker to resolve the linker errors for the methods mentioned? Also note that clang++ is a different compiler compared to g++ and hence need the static/shared libraries compiled prior by the same compiler you are using (clang++).
Try:
clang++ main.cpp -o out -lpng
Here's why: You are not providing the library that contains the implementation of your PNG library (libpng most likely). You need -lpng added to your compiler, so that it links with the relevant library. It may not be exactly -lpng in your particular case, but it's definitely a "missing library". Without knowing exactly what library you are trying to use (you didn't provide some source to "try the fix with").
As pointed out in the comment: you are using some kind of C++ wrapper on top, the above is probably not enough - but without knowing exactly which C++ wrapper on the png functionality you are actually using, it's hard to say what the command-line should look like.
Perhaps this
I got a problem when I rebuild cocos2d v2.1.5 with architecture x64 in xcode 6.3. please help me fix this.
Undefined symbols for architecture arm64:
"_WebPGetFeaturesInternal", referenced from:
WebPGetFeatures(unsigned char const*, unsigned long, WebPBitstreamFeatures*) in CCImageCommonWebp.o
"_WebPInitDecoderConfigInternal", referenced from:
WebPInitDecoderConfig(WebPDecoderConfig*) in CCImageCommonWebp.o
"_WebPDecode", referenced from:
cocos2d::CCImage::_initWithWebpData(void*, int) in CCImageCommonWebp.o
"_NEON_Matrix4Mul", referenced from:
_kmMat4Multiply in mat4.o
"_AES_decrypt", referenced from:
DataEncrypt::parseXMLData(unsigned long, char const*) in UserDataEncrypt.o
"_AES_set_encrypt_key", referenced from:
DataEncrypt::save() in UserDataEncrypt.o
"_AES_encrypt", referenced from:
DataEncrypt::save() in UserDataEncrypt.o
"_AES_set_decrypt_key", referenced from:
DataEncrypt::parseXMLData(unsigned long, char const*) in UserDataEncrypt.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
You have to update cocos2d to version 2.2.6. It's minimum version which supports x64 architecture. However it's not stable, so you'd better update to 3.6 if you have enough time.
Link to tutorial
We've started migration and it looks like it will take 80+ hours because of big changes in API.
I'm trying to use some frameworks with Xcode 4.6.2.
C++ frameworks, such as cppunit and boost that is supposed to be compiled and linked to in my projects always fails with "Undefined symbols for architecture x86_64[...]" or i386 for that matter when I'm trying different build settings.
I have tried setting Compiler to clang and g++ with various sets of cpu-architecture flags (64, 32 and 32_64). I have come to a point where I can't find any solutions on my own.
I've also tried the fail safe packages from without any luck:
brew install cppunit universal
port install cppunit +universal
(Also without success the Boost library)
Also, a lot of tries on Boost is done. Bjam has really made a lot of work the last 24 hours. Multiple settings has been tried:
http://www.codeproject.com/Tips/555070/Boost-vs-OSX-iOS-XCode and
http://boost.2283326.n4.nabble.com/Errors-compiling-Boost-Log-on-OS-X-tp4646151p4646299.html
And more in pure trial and error on my part.
So my question is: what are the combination of compiler and linker and the respective flags I should use in order to make it work in my Xcode projects?
Per request from Captain Obvlious, here are some errors when running an application with Boost::Test:
Undefined symbols for architecture x86_64:
"boost::test_tools::tt_detail::check_impl(boost::test_tools::predicate_result const&, boost::unit_test::lazy_ostream const&, boost::unit_test::basic_cstring<char const>, unsigned long, boost::test_tools::tt_detail::tool_level, boost::test_tools::tt_detail::check_type, unsigned long, ...)", referenced from:
my_test::test_method() in main.o
"boost::unit_test::unit_test_log_t::set_checkpoint(boost::unit_test::basic_cstring<char const>, unsigned long, boost::unit_test::basic_cstring<char const>)", referenced from:
my_test::test_method() in main.o
"boost::unit_test::framework::master_test_suite()", referenced from:
init_unit_test_suite(int, char**) in main.o
"boost::unit_test::test_case::test_case(boost::unit_test::basic_cstring<char const>, boost::unit_test::callback0<boost::unit_test::ut_detail::unused> const&)", referenced from:
boost::unit_test::make_test_case(boost::unit_test::callback0<boost::unit_test::ut_detail::unused> const&, boost::unit_test::basic_cstring<char const>) in main.o
"boost::unit_test::ut_detail::auto_test_unit_registrar::auto_test_unit_registrar(boost::unit_test::test_case*, unsigned long)", referenced from:
___cxx_global_var_init2 in main.o
"boost::unit_test::ut_detail::normalize_test_case_name(boost::unit_test::basic_cstring<char const>)", referenced from:
boost::unit_test::make_test_case(boost::unit_test::callback0<boost::unit_test::ut_detail::unused> const&, boost::unit_test::basic_cstring<char const>) in main.o
"vtable for boost::unit_test::unit_test_log_t", referenced from:
boost::unit_test::unit_test_log_t::unit_test_log_t() in main.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
You need to add whichever library those functions depend on via "Link Binary With Libraries" in the Build Phases of your Project. However, this then brings up the dreaded EXC_BAD_ACCESS you can read about elsewhere on Stack.
I'm trying to do some really simple stuff in C++, but I can't find any information on how to tackle this. Even the book I have just says "Just compile and run the program".
test.cpp
#include <iostream>
using namespace std;
int main()
{
cout << "Never fear, C++ is here!";
return 0;
}
The compiler says:
Undefined symbols for architecture x86_64:
"std::cout", referenced from:
_main in ccVfJHGs.o
"std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)", referenced from:
_main in ccVfJHGs.o
"std::ios_base::Init::Init()", referenced from:
__static_initialization_and_destruction_0(int, int)in ccVfJHGs.o
"std::ios_base::Init::~Init()", referenced from:
___tcf_0 in ccVfJHGs.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
I tried compiling with flags like -arch i386 and -m32 but it always says it's the wrong architecture. Which one should I use?
I'm doing this on a Mac but not using XCode, just gcc.
The error isn't that it's the wrong architecture, it's that std::cout (and other symbols) isn't defined.
You should compile and link with g++ not gcc, to automatically link with correct C++ libraries.
The error is caused because you're compiling with gcc, which only default-links libc.
You need to compile with g++ so that libstdc++ is auto-linked in too.
Use g++ instead of gcc to link with exact c++ libraries