using boost gregorian in iOS - c++

using: xcode 4.6.3. and boost 1.53.0
I'm trying to manipulate dates and times using 'boost::gregorian::days'. It's working perfectly fine when I'm building for OSX 10.8. The problem is when I'm trying to build an iOS app. Everything (including other boost functions) is working fine except the 'gregorian' part. I have used tons of different ways to build boost but I still can't seem to manage to get this part to work.
Is there any way to get this to work?
edit: forgot to mention, I've linked libboost_date_time.a to the project.
sample:
#include "boost/date_time/gregorian/gregorian.hpp"
#include <iostream>
int main()
{
int day = 5;
int month = 8;
int year = 2013;
boost::gregorian::date inputDate(year, month, day);
std::string stringDate = to_iso_extended_string(inputDate)
std::cout << stringDate;
return 0;
}
this gives me the error:
Undefined symbols for architecture i386:
"boost::gregorian::greg_month::as_long_string() const", referenced from:
boost::date_time::month_formatter<boost::gregorian::greg_month, boost::date_time::iso_extended_format<char>, char>::format_month(boost::gregorian::greg_month const&, std::__1::basic_ostream<char, std::__1::char_traits<char> >&) in myFile.o
"boost::gregorian::greg_month::as_short_string() const", referenced from:
boost::date_time::month_formatter<boost::gregorian::greg_month, boost::date_time::iso_extended_format<char>, char>::format_month(boost::gregorian::greg_month const&, std::__1::basic_ostream<char, std::__1::char_traits<char> >&) in myFile.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Related

OpenCV4 on XCode — opencv2/core.hpp not found

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?

Xcode 6.3 Apple Match-O linker Error with cocos2d v2.1.5 project

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.

How can I fix g++ Undefined symbols for architecture x86_64 error?

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.

Problems with BigInt Library in C++

So I'm trying out this bigint library: https://mattmccutchen.net/bigint/ on OSX Lion.
I tried making a simple file using the example on their site.
#include <iostream>
#include <bigint/BigIntegerLibrary.hh>
using namespace std;
int main(){
BigInteger a;
int b=5;
a=b;
cout<<a;
return 0;
}
When I compile this in textmate, the output is:
Undefined symbols for architecture x86_64:
  "BigInteger::BigInteger(int)", referenced from:
      _main in ccl9yNN5.o
  "BigInteger::operator=(BigInteger const&)", referenced from:
      _main in ccl9yNN5.o
  "operator<<(std::basic_ostream<char, std::char_traits<char> >&, BigInteger const&)", referenced from:
      _main in ccl9yNN5.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
Can anyone tell me what is wrong?
just in case anyone is still looking for answers to this. I found that you have to dig into the Makefile a little bit and figure out how to manually link the program using the Makefile. What I did is in the bigint folder, I ran "make library" once, then later on, I followed the samples at the very end of the Makefile to link the library files together. Here is my Makefile trying to solve an SPOJ problem:

Undefined symbols for architecture x86_64: Which architecture should I use?

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