Can't compile with libobjc2
Albert Palacios <[email protected]> Tue, 7 Feb 2023 19:48:36 +0000
| Newsgroups | gmane.comp.lib.gnustep.user |
|---|---|
| Message-ID | <CAGAwGxj9174dMPcigap3xfGvAFVSLzQ2raHhJWPXW7BsqsaCXw@mail.gmail.com> |
--0000000000009d61b305f4216fee
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
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=3Dclang -DCMAKE_CXX_COMPILER=3Dclang++
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=C3=B3n\n");
}
return 0;
}
But when I call:
clang main.m -fobjc-runtime=3Dgnustep-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
--0000000000009d61b305f4216fee
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Hi,<div><br></div><div>Maybe someone can help me.=C2=A0</d=
iv><div><br></div><div>I managed to install libobjc2 on Ubuntu 22.04 with:=
=C2=A0</div><div><br></div><div><font color=3D"#0b5394">sudo apt install cm=
ake<br>git clone <a href=3D"https://github.com/gnustep/libobjc2.git">https:=
//github.com/gnustep/libobjc2.git</a><br>cd libobjc2<br>git submodule init =
&& git submodule update<br>mkdir Build && cd Build<br>cmake=
.. -DCMAKE_C_COMPILER=3Dclang -DCMAKE_CXX_COMPILER=3Dclang++<br>make -j8<b=
r>sudo -E make install<br>sudo ldconfig</font><br></div><div><br></div><div=
>And I am trying to compile and run a very simple application:</div><div><b=
r></div><div><div style=3D"color:rgb(212,212,212);background-color:rgb(30,3=
0,30);font-family:"Droid Sans Mono","monospace",monospa=
ce;line-height:19px;white-space:pre"><div style=3D""><font size=3D"1"><span=
style=3D"color:rgb(197,134,192)">#include</span><span style=3D"color:rgb(8=
6,156,214)"> </span><span style=3D"color:rgb(206,145,120)"><stdio.h><=
/span></font></div><div style=3D""><font size=3D"1"><span style=3D"color:rg=
b(86,156,214)">int</span> <span style=3D"color:rgb(220,220,170)">main</span=
>() {</font></div><div style=3D""><font size=3D"1"> @autoreleasepool {</=
font></div><div style=3D""><font size=3D"1"> <span style=3D"color:r=
gb(220,220,170)">printf</span>(<span style=3D"color:rgb(206,145,120)">"=
;Hola m=C3=B3n</span><span style=3D"color:rgb(215,186,125)">\n</span><span =
style=3D"color:rgb(206,145,120)">"</span>);</font></div><div style=3D"=
"><font size=3D"1"> }</font></div><div style=3D""><font size=3D"1"> <=
span style=3D"color:rgb(197,134,192)">return</span> <span style=3D"color:rg=
b(181,206,168)">0</span>;</font></div><div style=3D""><font size=3D"1">}</f=
ont></div></div></div><div><br></div><div>But when I call:</div><div><br></=
div><div><font color=3D"#0b5394">clang main.m -fobjc-runtime=3Dgnustep-2.0 =
-o main && ./main<br></font></div><div><br></div><div>I get the nex=
t error:</div><div><br></div><div><font color=3D"#0b5394">/usr/bin/ld: /tmp=
/main-f8c82f.o: in function `main':<br>main.m:(.text+0x18): undefined r=
eference to `objc_autoreleasePoolPush'<br>/usr/bin/ld: main.m:(.text+0x=
30): undefined reference to `objc_autoreleasePoolPop'<br>/usr/bin/ld: /=
tmp/main-f8c82f.o: in function `.objcv2_load_function':<br>main.m:(.tex=
t..objcv2_load_function[.objcv2_load_function]+0xc): undefined reference to=
`__objc_load'<br>clang: error: linker command failed with exit code 1 =
(use -v to see invocation)<br></font></div><div><br></div><div>Thanks,</div=
><div><br></div><div>Albert</div></div>
--0000000000009d61b305f4216fee--