Author Topic: Set LLVM compiller  (Read 2776 times)

Offline mariusm

  • Multiple posting newcomer
  • *
  • Posts: 46
Set LLVM compiller
« on: February 11, 2023, 01:30:37 pm »
I want to use on old OSX with llvm-gcc compiler. I had success with Gcc compiler in this OSX but not llvm.

Do not see llvm-gcc executable on the list compilers.

How to set this compiler?

Online Commaster

  • Almost regular
  • **
  • Posts: 171
Re: Set LLVM compiller
« Reply #1 on: February 11, 2023, 03:53:56 pm »
https://forums.codeblocks.org/index.php/topic,9996.0.html

Code::Blocks is not a compiler. You have to install llvm-gcc (I assume you mean clang) yourself first.

Offline mariusm

  • Multiple posting newcomer
  • *
  • Posts: 46
Re: Set LLVM compiller
« Reply #2 on: February 11, 2023, 04:25:29 pm »
I don't say Code::Blocks it's a compiler  ;D

Already have installed the compiler and works with xCode but not with Code::Blocks  :'(

In the compiler list I see only clang++ for "LLVM Clang Compiler" CB entry which is not executable for llvm-gcc
« Last Edit: February 11, 2023, 04:28:25 pm by mariusm »

Online Commaster

  • Almost regular
  • **
  • Posts: 171
Re: Set LLVM compiller
« Reply #3 on: February 11, 2023, 05:23:39 pm »
Those are just preset values, you are free to change the executable names (and paths)  ;)

Offline mariusm

  • Multiple posting newcomer
  • *
  • Posts: 46
Re: Set LLVM compiller
« Reply #4 on: February 11, 2023, 06:50:49 pm »
I understand but I don't know how.

I found the executable for the C++ compiler but I can not find the executable for the linker (very important) also not for the C compiler.

I search on the llvm-gcc documentation but cannot find this informations.

Offline mariusm

  • Multiple posting newcomer
  • *
  • Posts: 46
Re: Set LLVM compiller
« Reply #5 on: February 12, 2023, 11:39:04 pm »
Finally I solve the compiler problem. I installed another version of Clang LLVM that is compatible with C::B.

Now I get other problem when try to build an example:

Code
#include <iostream>
using namespace std;
int main() {
    cout << "Hello world!" << endl;
    return 0;
}

fatal error: iostream: No such file or directory

I use Main.cpp not Main.c


Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline mariusm

  • Multiple posting newcomer
  • *
  • Posts: 46
Re: Set LLVM compiller
« Reply #7 on: February 13, 2023, 09:20:32 am »
I changed the code to

Code
#include <stdio.h>

int main() {
printf("Hello world!\n");
    return 0;
}

------------- Clean: Release in Test (compiler: LLVM Clang Compiler)---------------

Cleaned "Test - Release"

-------------- Build: Release in Test (compiler: LLVM Clang Compiler)---------------

clang++ -Weverything -fexceptions  -O2  -ObjC++   -I/Developer/usr/clang_llvm-3.1/include -I/Developer/SDKs/MacOSX10.6.sdk/usr/include -c /Volumes/D/C++/Test/Test/main.cpp -o "Release tmp/main.o"
In file included from /Volumes/D/C++/Test/Test/main.cpp:1:
In file included from /Developer/SDKs/MacOSX10.6.sdk/usr/include/stdio.h:64:
In file included from /Developer/SDKs/MacOSX10.6.sdk/usr/include/_types.h:27:
In file included from /Developer/SDKs/MacOSX10.6.sdk/usr/include/sys/_types.h:32:
/Developer/SDKs/MacOSX10.6.sdk/usr/include/sys/cdefs.h:174:5: warning: '__STDC_VERSION__' is not defined, evaluates to 0 [-Wundef]
#if __STDC_VERSION__ < 199901
    ^
In file included from /Volumes/D/C++/Test/Test/main.cpp:1:
In file included from /Developer/SDKs/MacOSX10.6.sdk/usr/include/stdio.h:64:
In file included from /Developer/SDKs/MacOSX10.6.sdk/usr/include/_types.h:27:
In file included from /Developer/SDKs/MacOSX10.6.sdk/usr/include/sys/_types.h:33:
In file included from /Developer/SDKs/MacOSX10.6.sdk/usr/include/machine/_types.h:34:
/Developer/SDKs/MacOSX10.6.sdk/usr/include/i386/_types.h:46:9: warning: 'long long' is an extension when C99 mode is not enabled [-pedantic,-Wlong-long]
typedef long long               __int64_t;
        ^
/Developer/SDKs/MacOSX10.6.sdk/usr/include/i386/_types.h:47:18: warning: 'long long' is an extension when C99 mode is not enabled [-pedantic,-Wlong-long]
typedef unsigned long long      __uint64_t;
                 ^
/Developer/SDKs/MacOSX10.6.sdk/usr/include/i386/_types.h:78:2: warning: 'long long' is an extension when C99 mode is not enabled [-pedantic,-Wlong-long]
        long long       _mbstateL;                      /* for alignment */
        ^
In file included from /Volumes/D/C++/Test/Test/main.cpp:1:
/Developer/SDKs/MacOSX10.6.sdk/usr/include/stdio.h:397:23: warning: implicit conversion loses integer precision: 'int' to 'unsigned char' [-Wconversion]
                return (*_p->_p++ = _c);
                                  ~ ^~
5 warnings generated.
clang++ -L/Developer/SDKs/MacOSX10.6.sdk/usr/lib -o Release/Test "Release tmp/main.o"  -s 
clang: error: unable to execute command: posix_spawn failed: No such file or directory
clang: error: linker command failed due to signal (use -v to see invocation)
Process terminated with status 255 (0 minute(s), 1 second(s))
1 error(s), 5 warning(s) (0 minute(s), 1 second(s))
 

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1563
Re: Set LLVM compiller
« Reply #8 on: February 13, 2023, 01:48:06 pm »
Rename main.cpp as main.c and try again.

Offline mariusm

  • Multiple posting newcomer
  • *
  • Posts: 46
Re: Set LLVM compiller
« Reply #9 on: February 13, 2023, 03:17:12 pm »
For what ? I need to set C++ compiler not C. Anyway , there it's C++ code not C

Offline mariusm

  • Multiple posting newcomer
  • *
  • Posts: 46
Re: Set LLVM compiller
« Reply #10 on: February 13, 2023, 05:43:54 pm »
I solve posix error but get another:


-------------- Clean: LLVM in Test (compiler: LLVM Clang Compiler)---------------

Cleaned "Test - LLVM"

-------------- Build: LLVM in Test (compiler: LLVM Clang Compiler)---------------

clang++  -fexceptions -v    -I/Developer/usr/clang_llvm-3.1/include -I/Developer/SDKs/MacOSX10.6.sdk/usr/include -c /Volumes/D/C++/Test/Test/main.cpp -o "Release tmp/main.o"
clang version 3.1 (tags/RELEASE_31/final)
Target: x86_64-apple-darwin12.3.0
Thread model: posix
 "/Developer/usr/clang_llvm-3.1/bin/clang" -cc1 -triple x86_64-apple-macosx10.8.0 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name main.cpp -pic-level 2 -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 123.2.1 -v -coverage-file "Release tmp/main.o" -resource-dir /Developer/usr/clang_llvm-3.1/bin/../lib/clang/3.1 -I /Developer/usr/clang_llvm-3.1/include -I /Developer/SDKs/MacOSX10.6.sdk/usr/include -fmodule-cache-path /var/folders/8j/zw7_bb6s4fsg036jd3p54y0m0000gn/T/clang-module-cache -fdeprecated-macro -fdebug-compilation-dir /Volumes/D/C++/Test/Test -ferror-limit 19 -fmessage-length 0 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime-has-arc -fobjc-runtime-has-weak -fobjc-dispatch-method=mixed -fobjc-default-synthesize-properties -fcxx-exceptions -fexceptions -fdiagnostics-show-option -o "Release tmp/main.o" -x c++ /Volumes/D/C++/Test/Test/main.cpp
clang -cc1 version 3.1 based upon LLVM 3.1 default target x86_64-apple-darwin12.3.0
ignoring nonexistent directory "/usr/include/c++/4.2.1"
ignoring nonexistent directory "/usr/include/c++/4.2.1/i686-apple-darwin10/x86_64"
ignoring nonexistent directory "/usr/include/c++/4.2.1/backward"
ignoring nonexistent directory "/usr/include/c++/4.0.0"
ignoring nonexistent directory "/usr/include/c++/4.0.0/i686-apple-darwin8/"
ignoring nonexistent directory "/usr/include/c++/4.0.0/backward"
ignoring nonexistent directory "/usr/local/include"
#include "..." search starts here:
#include <...> search starts here:
 /Developer/usr/clang_llvm-3.1/include
 /Developer/SDKs/MacOSX10.6.sdk/usr/include
 /Developer/usr/clang_llvm-3.1/bin/../lib/clang/3.1/include
 /usr/include
 /System/Library/Frameworks (framework directory)
 /Library/Frameworks (framework directory)
End of search list.
clang++ -L/Developer/usr/clang_llvm-3.1/lib -o Release/Test "Release tmp/main.o"   
ld: unknown option: -demangle
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Offline mariusm

  • Multiple posting newcomer
  • *
  • Posts: 46
Re: Set LLVM compiller
« Reply #11 on: February 14, 2023, 11:15:23 am »
That was because missed -isysroot option for SDK path