Hi,
Maybe someone can help me.
I managed to install libobjc2 on Ubuntu 22.04 with:
sudo apt install cmake
git clone https://github.com/gnustep/libobjc2.git
cd libobjc2
git submodule init && git submodule update
mkdir Build && cd Build
cmake .. -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
make -j8
sudo -E make install
sudo ldconfig
And I am trying to compile and run a very simple application:
#include <stdio.h>
int main() {
@autoreleasepool {
printf("Hola món\n");
}
return 0;
}
But when I call:
clang main.m -fobjc-runtime=gnustep-2.0 -o main && ./main
I get the next error:
/usr/bin/ld: /tmp/main-f8c82f.o: in function `main':
main.m:(.text+0x18): undefined reference to `objc_autoreleasePoolPush'
/usr/bin/ld: main.m:(.text+0x30): undefined reference to `objc_autoreleasePoolPop'
/usr/bin/ld: /tmp/main-f8c82f.o: in function `.objcv2_load_function':
main.m:(.text..objcv2_load_function[.objcv2_load_function]+0xc): undefined reference to `__objc_load'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Thanks,
Albert