user40
user40

Reputation: 1396

C++: Running code (created in Linux) on Mac OS X, Qt 5.0

When I run project that was created in Linux I get error in the "std::cout<<..." line:

void Assert(bool condition, std::string message)
  {
    if(!condition)
     {
        std::cout<<"message"<<message<<std::endl;
        int s = 4/0;
     }
}

Error message:

/MainData.cpp:159: error: explicit instantiation of 'std::basic_ostream<_CharT,
_Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const
std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = 
std::char_traits<char>, _Alloc = std::allocator<char>]' but no definition available

include lines:

#include"iostream"
#include"vector"
#include "math.h"
#include"cstdlib"
#include "string"

What could be the reason?

Upvotes: 0

Views: 109

Answers (1)

Joe Z
Joe Z

Reputation: 17956

It appears this is a MacOS specific quirk, solved by adding the compiler flag -mmacosx-version-min=10.7.

Specifically (as the first link below states), add these two lines to your .pro file:

QMAKE_CFLAGS_X86_64 += -mmacosx-version-min=10.7
QMAKE_CXXFLAGS_X86_64 = $$QMAKE_CFLAGS_X86_64

Supporting links:

Upvotes: 2

Related Questions