clang-omp / clang

clang with OpenMP 3.1 and some elements of OpenMP 4.0 support
clang-omp.github.com
Other
91 stars 15 forks source link

Undefined symbols for architecture x86_64 #62

Closed igorbelykh86 closed 9 years ago

igorbelykh86 commented 9 years ago

Hello,

I've installed the clang-omp successfully but now I have following errors during compilation

"/Applications/Xcode.app/Contents/Developer/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
"/Applications/Xcode.app/Contents/Developer/usr/bin/make"  -f nbproject/Makefile-Debug.mk dist/Debug/CLang-MacOSX/ib-grnn-tester
mkdir -p build/Debug/CLang-MacOSX/lib
rm -f "build/Debug/CLang-MacOSX/lib/IB_GRnn.o.d"
gcc -fopenmp   -c -g -I../lib/llvm/build/include -I/usr/local/include -I/usr/include/c++/4.2.1 -std=c++11 -MMD -MP -MF "build/Debug/CLang-MacOSX/lib/IB_GRnn.o.d" -o build/Debug/CLang-MacOSX/lib/IB_GRnn.o lib/IB_GRnn.cpp
clang: warning: argument unused during compilation: '-fopenmp'

and

"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.10.0 -o dist/Debug/CLang-MacOSX/ib-grnn-tester build/Debug/CLang-MacOSX/lib/IB_GRnn.o build/Debug/CLang-MacOSX/lib/IB_GRnnInputLayer.o build/Debug/CLang-MacOSX/lib/IB_GRnnInputNeuron.o build/Debug/CLang-MacOSX/lib/IB_GRnnPatternLayer.o build/Debug/CLang-MacOSX/lib/IB_GRnnPatternNeuron.o build/Debug/CLang-MacOSX/lib/IB_GRnnResultLayer.o build/Debug/CLang-MacOSX/lib/IB_GRnnSummationLayer.o build/Debug/CLang-MacOSX/lib/IB_GRnnSummationNeuron.o build/Debug/CLang-MacOSX/main.o -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0/lib/darwin/libclang_rt.osx.a
Undefined symbols for architecture x86_64:
  "std::string::c_str() const", referenced from:
      symbolExists(std::string const*, char const*) in main.o
      loadHistory(std::map<std::string, std::vector<bar, std::allocator<bar> >, std::less<std::string>, std::allocator<std::pair<std::string const, std::vector<bar, std::allocator<bar> > > > >&, char const*, std::string const*) in main.o

I use Netbeans.

Best regards Igor

alexey-bataev commented 9 years ago

Igor, I think your gcc points to your original clang, not clang from clang-omp build. I think you need to modify your makefile so it could use clang compiler from clang-omp rather than gcc.

Best regards,

Alexey Bataev

Software Engineer Intel Compiler Team Intel Corp.

02.02.2015 18:25, igorbelykh86 пишет:

Hello,

I've installed the clang-omp successfully but now I have following errors during compilation

"/Applications/Xcode.app/Contents/Developer/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf "/Applications/Xcode.app/Contents/Developer/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/CLang-MacOSX/ib-grnn-tester mkdir -p build/Debug/CLang-MacOSX/lib rm -f "build/Debug/CLang-MacOSX/lib/IB_GRnn.o.d" gcc -fopenmp -c -g -I../lib/llvm/build/include -I/usr/local/include -I/usr/include/c++/4.2.1 -std=c++11 -MMD -MP -MF "build/Debug/CLang-MacOSX/lib/IB_GRnn.o.d" -o build/Debug/CLang-MacOSX/lib/IB_GRnn.o lib/IB_GRnn.cpp clang: warning: argument unused during compilation: '-fopenmp'

and

"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.10.0 -o dist/Debug/CLang-MacOSX/ib-grnn-tester build/Debug/CLang-MacOSX/lib/IB_GRnn.o build/Debug/CLang-MacOSX/lib/IB_GRnnInputLayer.o build/Debug/CLang-MacOSX/lib/IB_GRnnInputNeuron.o build/Debug/CLang-MacOSX/lib/IB_GRnnPatternLayer.o build/Debug/CLang-MacOSX/lib/IB_GRnnPatternNeuron.o build/Debug/CLang-MacOSX/lib/IB_GRnnResultLayer.o build/Debug/CLang-MacOSX/lib/IB_GRnnSummationLayer.o build/Debug/CLang-MacOSX/lib/IB_GRnnSummationNeuron.o build/Debug/CLang-MacOSX/main.o -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0/lib/darwin/libclang_rt.osx.a Undefined symbols for architecture x86_64: "std::string::cstr() const", referenced from: symbolExists(std::string const, char const) in main.o loadHistory(std::map<std::string, std::vector<bar, std::allocator >, std::lessstd::string, std::allocator<std::pair<std::string const, std::vector<bar, std::allocator > > > >&, char const, std::string const_) in main.o

I use Netbeans.

Best regards Igor

— Reply to this email directly or view it on GitHub https://github.com/clang-omp/clang/issues/62.

igorbelykh86 commented 9 years ago

That was right. I've fixed this thing but I still have the second error. Here's test program:

#include <stdio.h>
#include <iostream>

int main(int argc, char** argv) {
    int i;
    for(i = 0; i < 10; ++i) {
        std::cout << "Hello World (" << i << ")" << std::endl;
    }
    return 0;
}

Building result:

"/Applications/Xcode.app/Contents/Developer/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
"/Applications/Xcode.app/Contents/Developer/usr/bin/make"  -f nbproject/Makefile-Debug.mk dist/Debug/CLang-MacOSX/test-proj
mkdir -p build/Debug/CLang-MacOSX
rm -f "build/Debug/CLang-MacOSX/main.o.d"
/usr/local/bin/clang++ -fopenmp -isystem /Library/Developer/CommandLineTools/usr/include/c++/v1 -v   -c -g -I../lib/llvm/build/include -I/usr/local/include -I/usr/local/Cellar/gcc/4.9.2_1 -I/usr/include/c++/4.2.1 -MMD -MP -MF "build/Debug/CLang-MacOSX/main.o.d" -o build/Debug/CLang-MacOSX/main.o main.cpp
clang version 3.5.0 (https://github.com/clang-omp/clang b2fc5b326873b2f3bb919d11fe7f74981b517a79) (https://github.com/clang-omp/llvm e45b045553e027cbe400cbb8ac8c264abbbfaf83)
Target: x86_64-apple-darwin14.1.0
Thread model: posix
 "/usr/local/bin/clang" -cc1 -fopenmp -omp-main-file-path main.cpp -triple x86_64-apple-macosx10.10.0 -emit-obj -mrelax-all -disable-free -main-file-name main.cpp -mrelocation-model pic -pic-level 2 -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 241.9 -v -gdwarf-2 -dwarf-column-info -coverage-file /Users/igor/PrivateProjects/test-proj/build/Debug/CLang-MacOSX/main.o -resource-dir /usr/local/bin/../lib/clang/3.5.0 -dependency-file build/Debug/CLang-MacOSX/main.o.d -MT build/Debug/CLang-MacOSX/main.o -MP -isystem /Library/Developer/CommandLineTools/usr/include/c++/v1 -I ../lib/llvm/build/include -I /usr/local/include -I /usr/local/Cellar/gcc/4.9.2_1 -I /usr/include/c++/4.2.1 -stdlib=libc++ -fdeprecated-macro -fdebug-compilation-dir /Users/igor/PrivateProjects/test-proj -ferror-limit 19 -fmessage-length 0 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime=macosx-10.10.0 -fencode-extended-block-signature -fcxx-exceptions -fexceptions -fdiagnostics-show-option -o build/Debug/CLang-MacOSX/main.o -x c++ main.cpp
clang -cc1 version 3.5.0 based upon LLVM 3.5.0 default target x86_64-apple-darwin14.1.0
ignoring nonexistent directory "../lib/llvm/build/include"
ignoring nonexistent directory "/usr/local/bin/../include/c++/v1"
ignoring nonexistent directory "/usr/include/c++/v1"
ignoring duplicate directory "/usr/local/include"
  as it is a non-system directory that duplicates a system directory
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/Cellar/gcc/4.9.2_1
 /usr/include/c++/4.2.1
 /Library/Developer/CommandLineTools/usr/include/c++/v1
 /usr/local/include
 /usr/local/bin/../lib/clang/3.5.0/include
 /usr/include
 /System/Library/Frameworks (framework directory)
 /Library/Frameworks (framework directory)
End of search list.
mkdir -p dist/Debug/CLang-MacOSX
/usr/local/bin/clang -o dist/Debug/CLang-MacOSX/test-proj build/Debug/CLang-MacOSX/main.o  -v
clang version 3.5.0 (https://github.com/clang-omp/clang b2fc5b326873b2f3bb919d11fe7f74981b517a79) (https://github.com/clang-omp/llvm e45b045553e027cbe400cbb8ac8c264abbbfaf83)
Target: x86_64-apple-darwin14.1.0
Thread model: posix
 "/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.10.0 -o dist/Debug/CLang-MacOSX/test-proj build/Debug/CLang-MacOSX/main.o -lSystem /usr/local/bin/../lib/clang/3.5.0/lib/darwin/libclang_rt.osx.a
Undefined symbols for architecture x86_64:
  "std::ostream::operator<<(std::ostream& (*)(std::ostream&))", referenced from:
      _main in main.o
  "std::ostream::operator<<(int)", referenced from:
      _main in main.o
  "std::ios_base::Init::Init()", referenced from:
      ___cxx_global_var_init in main.o
  "std::ios_base::Init::~Init()", referenced from:
      ___cxx_global_var_init in main.o
  "std::cout", referenced from:
      _main in main.o
  "std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)", referenced from:
      _main in main.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 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)
make[2]: *** [dist/Debug/CLang-MacOSX/test-proj] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2

Thanks, Igor

alexey-bataev commented 9 years ago

Hmm, it seems you're using libstdc++ from gcc 4.9.1. But you did not provided path to libstdc++ library to linker.

Best regards,

Alexey Bataev

Software Engineer Intel Compiler Team Intel Corp.

03.02.2015 10:16, igorbelykh86 пишет:

That was right. I've fixed this thing but I still have the second error. Here's test program:

|#include

include

int main(int argc, char\ argv) { int i; for(i = 0; i < 10; ++i) { std::cout << "Hello World (" << i << ")" << std::endl; } return 0; } |

Building result:

|"/Applications/Xcode.app/Contents/Developer/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf "/Applications/Xcode.app/Contents/Developer/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/CLang-MacOSX/test-proj mkdir -p build/Debug/CLang-MacOSX rm -f "build/Debug/CLang-MacOSX/main.o.d" /usr/local/bin/clang++ -fopenmp -isystem /Library/Developer/CommandLineTools/usr/include/c++/v1 -v -c -g -I../lib/llvm/build/include -I/usr/local/include -I/usr/local/Cellar/gcc/4.9.2_1 -I/usr/include/c++/4.2.1 -MMD -MP -MF "build/Debug/CLang-MacOSX/main.o.d" -o build/Debug/CLang-MacOSX/main.o main.cpp clang version 3.5.0 (https://github.com/clang-omp/clang b2fc5b326873b2f3bb919d11fe7f74981b517a79) (https://github.com/clang-omp/llvm e45b045553e027cbe400cbb8ac8c264abbbfaf83) Target: x86_64-apple-darwin14.1.0 Thread model: posix "/usr/local/bin/clang" -cc1 -fopenmp -omp-main-file-path main.cpp -triple x86_64-apple-macosx10.10.0 -emit-obj -mrelax-all -disable-free -main-file-name main.cpp -mrelocation-model pic -pic-level 2 -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 241.9 -v -gdwarf-2 -dwarf-column-info -coverage-file /Users/igor/PrivateProjects/test-proj/build/Debug/CLang-MacOSX/main.o -resource-dir /usr/local/bin/../lib/clang/3.5.0 -dependency-file build/Debug/CLang-MacOSX/main.o.d -MT build/Debug/CLang-MacOSX/main.o -MP -isystem /Library/Developer/CommandLineTools/usr/include/c++/v1 -I ../lib/llvm/build/include -I /usr/local/include -I /usr/local/Cellar/gcc/4.9.2_1 -I /usr/include/c++/4.2.1 -stdlib=libc++ -fdeprecated-macro -fdebug-compilation-dir /Users/igor/PrivateProjects/test-proj -ferror-limit 19 -fmessage-length 0 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime=macosx-10.10.0 -fencode-extended-block-signature -fcxx-exceptions -fexceptio ns -fdia gnostics-show-option -o build/Debug/CLang-MacOSX/main.o -x c++ main.cpp clang -cc1 version 3.5.0 based upon LLVM 3.5.0 default target x86_64-apple-darwin14.1.0 ignoring nonexistent directory "../lib/llvm/build/include" ignoring nonexistent directory "/usr/local/bin/../include/c++/v1" ignoring nonexistent directory "/usr/include/c++/v1" ignoring duplicate directory "/usr/local/include" as it is a non-system directory that duplicates a system directory

include "..." search starts here:

include <...> search starts here:

/usr/local/Cellar/gcc/4.9.2_1 /usr/include/c++/4.2.1 /Library/Developer/CommandLineTools/usr/include/c++/v1 /usr/local/include /usr/local/bin/../lib/clang/3.5.0/include /usr/include /System/Library/Frameworks (framework directory) /Library/Frameworks (framework directory) End of search list. mkdir -p dist/Debug/CLang-MacOSX /usr/local/bin/clang -o dist/Debug/CLang-MacOSX/test-proj build/Debug/CLang-MacOSX/main.o -v clang version 3.5.0 (https://github.com/clang-omp/clang b2fc5b326873b2f3bb919d11fe7f74981b517a79) (https://github.com/clang-omp/llvm e45b045553e027cbe400cbb8ac8c264abbbfaf83) Target: x86_64-apple-darwin14.1.0 Thread model: posix "/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.10.0 -o dist/Debug/CLang-MacOSX/test-proj build/Debug/CLang-MacOSX/main.o -lSystem /usr/local/bin/../lib/clang/3.5.0/lib/darwin/libclang_rt.osx.a Undefined symbols for architecture x8664: "std::ostream::operator<<(std::ostream& ()(std::ostream&))", referenced from: _main in main.o "std::ostream::operator<<(int)", referenced from: _main in main.o "std::ios_base::Init::Init()", referenced from: _cxx_global_var_init in main.o "std::iosbase::Init::~Init()", referenced from: cxx_global_var_init in main.o "std::cout", referenced from: _main in main.o "std::basic_ostream<char, std::char_traits >& std::endl<char, std::char_traits >(std::basic_ostream<char, std::char_traits >&)", referenced from: _main in main.o "std::basic_ostream<char, std::char_traits >& std::operator<<std::char_traits(std::basic_ostream<char, std::chartraits >&, char const)", 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) make[2]: * [dist/Debug/CLang-MacOSX/test-proj] Error 1 make[1]: * [.build-conf] Error 2 make: *\ [.build-impl] Error 2 |

Thanks, Igor

— Reply to this email directly or view it on GitHub https://github.com/clang-omp/clang/issues/62#issuecomment-72605353.

igorbelykh86 commented 9 years ago

Yeah, after I have provided the path to libstdc++ it works great. But pragma omp doesn't work. I think I have to provide one more library to linker but what exact? Build result:

"/Applications/Xcode.app/Contents/Developer/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
"/Applications/Xcode.app/Contents/Developer/usr/bin/make"  -f nbproject/Makefile-Debug.mk dist/Debug/CLang-MacOSX/test-proj
mkdir -p dist/Debug/CLang-MacOSX
/usr/local/bin/clang -o dist/Debug/CLang-MacOSX/test-proj build/Debug/CLang-MacOSX/main.o -L/usr/lib -L/usr/local/lib/clang/3.5.0/lib -L/usr/local/Cellar/gcc/4.9.2_1/lib -v -lSystem /usr/lib/libstdc++.dylib
clang version 3.5.0 (https://github.com/clang-omp/clang b2fc5b326873b2f3bb919d11fe7f74981b517a79) (https://github.com/clang-omp/llvm e45b045553e027cbe400cbb8ac8c264abbbfaf83)
Target: x86_64-apple-darwin14.1.0
Thread model: posix
 "/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.10.0 -o dist/Debug/CLang-MacOSX/test-proj -L/usr/lib -L/usr/local/lib/clang/3.5.0/lib -L/usr/local/Cellar/gcc/4.9.2_1/lib build/Debug/CLang-MacOSX/main.o -lSystem /usr/lib/libstdc++.dylib -lSystem /usr/local/bin/../lib/clang/3.5.0/lib/darwin/libclang_rt.osx.a
Undefined symbols for architecture x86_64:
  "___kmpc_cancel_barrier", referenced from:
      _.omp_microtask. in main.o
  "___kmpc_fork_call", 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)
make[2]: *** [dist/Debug/CLang-MacOSX/test-proj] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2

Thanks, Igor

alexey-bataev commented 9 years ago

Hi, add option -fopenmp to clang compiler and provide a path to libiomp5 runtime library. You should build this runtime library yourself using source code from openmp.llvm.org

Best regards,

Alexey Bataev

Software Engineer Intel Compiler Team Intel Corp.

03.02.2015 17:36, igorbelykh86 пишет:

Yeah, after I have provided the path to libstdc++ it works great. But pragma omp doesn't work. I think I have to provide one more library to linker but what exact? Build result:

"/Applications/Xcode.app/Contents/Developer/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf "/Applications/Xcode.app/Contents/Developer/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/CLang-MacOSX/test-proj mkdir -p dist/Debug/CLang-MacOSX /usr/local/bin/clang -o dist/Debug/CLang-MacOSX/test-proj build/Debug/CLang-MacOSX/main.o -L/usr/lib -L/usr/local/lib/clang/3.5.0/lib -L/usr/local/Cellar/gcc/4.9.2_1/lib -v -lSystem /usr/lib/libstdc++.dylib clang version 3.5.0 (https://github.com/clang-omp/clang b2fc5b326873b2f3bb919d11fe7f74981b517a79) (https://github.com/clang-omp/llvm e45b045553e027cbe400cbb8ac8c264abbbfaf83) Target: x86_64-apple-darwin14.1.0 Thread model: posix "/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.10.0 -o dist/Debug/CLang-MacOSX/test-proj -L/usr/lib -L/usr/local/lib/clang/3.5.0/lib -L/usr/local/Cellar/gcc/4.9.2_1/lib build/Debug/CLang-MacOSX/main.o -lSystem /usr/lib/libstdc++.dylib -lSystem /usr/local/bin/../lib/clang/3.5.0/lib/darwin/libclang_rt.osx.a Undefined symbols for architecture x86_64: "_kmpc_cancelbarrier", referenced from: .ompmicrotask. in main.o "kmpc_fork_call", 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) make[2]: * [dist/Debug/CLang-MacOSX/test-proj] Error 1 make[1]: * [.build-conf] Error 2 make: *\ [.build-impl] Error 2

Thanks, Igor

— Reply to this email directly or view it on GitHub https://github.com/clang-omp/clang/issues/62#issuecomment-72660233.

igorbelykh86 commented 9 years ago

Thank you very much!!!! It's working perfectly now :)

Regards, Igor

alexey-bataev commented 9 years ago

No problems

Best regards,

Alexey Bataev

Software Engineer Intel Compiler Team Intel Corp.

04.02.2015 21:13, igorbelykh86 пишет:

Thank you very much!!!! It's working perfectly now :)

Regards, Igor

— Reply to this email directly or view it on GitHub https://github.com/clang-omp/clang/issues/62#issuecomment-72907160.