Obj-C on Linux

Luminary
Posts: 5,143
Joined: 2002.04
Post: #31
Are there any other libs in the same place as libgnustep-base.so?

[font=monaco,courier]find /usr/lib -type f -name '*.so' | xargs nm | grep objc_lookup_class[/font] will at least tell you if any of the libraries in /usr/lib define objc_lookup_class. Probably also worth running a similar command on /usr/GNUstep/System/Libraries .
Quote this message in a reply
Member
Posts: 370
Joined: 2002.04
Post: #32
For /usr/lib, it prints a bunch of lines saying 'no symbols'

When I tried the second one, it printed a line saying
'nm: a.out: No such file or directory.'

So I then ran nm on libgnustep-base.so and piped it thru grep, and it returned this:

Quote: U objc_lookup_class

Now, trying again:

Quote:steven@hplmss1:~/war$ gcc -lgnustep-base -lobjc Card.m CardStack.m main.m
Card.m:9:2: warning: #import is obsolete, use an #ifndef wrapper in the header file
CardStack.m:9:2: warning: #import is obsolete, use an #ifndef wrapper in the header file
main.m:1:2: warning: #import is obsolete, use an #ifndef wrapper in the header file
/usr/GNUstep/System/Libraries/powerpc/linux-gnu/gnu-gnu-gnu/libgnustep-base.so: undefined reference to `dlerror'
/usr/GNUstep/System/Libraries/powerpc/linux-gnu/gnu-gnu-gnu/libgnustep-base.so: undefined reference to `ceil'
/usr/GNUstep/System/Libraries/powerpc/linux-gnu/gnu-gnu-gnu/libgnustep-base.so: undefined reference to `floor'
/usr/GNUstep/System/Libraries/powerpc/linux-gnu/gnu-gnu-gnu/libgnustep-base.so: undefined reference to `dlclose'
/usr/GNUstep/System/Libraries/powerpc/linux-gnu/gnu-gnu-gnu/libgnustep-base.so: undefined reference to `rint'
/usr/GNUstep/System/Libraries/powerpc/linux-gnu/gnu-gnu-gnu/libgnustep-base.so: undefined reference to `dlopen'
/usr/GNUstep/System/Libraries/powerpc/linux-gnu/gnu-gnu-gnu/libgnustep-base.so: undefined reference to `pow'
/usr/GNUstep/System/Libraries/powerpc/linux-gnu/gnu-gnu-gnu/libgnustep-base.so: undefined reference to `dlsym'
collect2: ld returned 1 exit status
steven@hplmss1:~/war$
Looks like I'm getting there.

I'll try adding -ldl to the command line.

Quote:steven@hplmss1:~/war$ gcc -lgnustep-base -lobjc -ldl Card.m CardStack.m main.m
Card.m:9:2: warning: #import is obsolete, use an #ifndef wrapper in the header file
CardStack.m:9:2: warning: #import is obsolete, use an #ifndef wrapper in the header file
main.m:1:2: warning: #import is obsolete, use an #ifndef wrapper in the header file
/usr/GNUstep/System/Libraries/powerpc/linux-gnu/gnu-gnu-gnu/libgnustep-base.so: undefined reference to `ceil'
/usr/GNUstep/System/Libraries/powerpc/linux-gnu/gnu-gnu-gnu/libgnustep-base.so: undefined reference to `floor'
/usr/GNUstep/System/Libraries/powerpc/linux-gnu/gnu-gnu-gnu/libgnustep-base.so: undefined reference to `rint'
/usr/GNUstep/System/Libraries/powerpc/linux-gnu/gnu-gnu-gnu/libgnustep-base.so: undefined reference to `pow'
collect2: ld returned 1 exit status
steven@hplmss1:~/war$
Gah! Down to four errors. Where would the above be?
Thanks a bunch,
Steven

Did you ever wonder why we had to run for shelter when the promise of a brave new world unfurled beneath the clear blue sky?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #33
-lm
Quote this message in a reply
Member
Posts: 370
Joined: 2002.04
Post: #34
WOOHOO!
It works! Now, can I have all of those -l parameters as the default or something? I don't want to have to write them over and over again.
Thanks a bunch OSC.
Steven

Did you ever wonder why we had to run for shelter when the promise of a brave new world unfurled beneath the clear blue sky?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #35
You only need them in the linking command, not in the commands to compile individual source files...
Quote this message in a reply
Member
Posts: 370
Joined: 2002.04
Post: #36
Yeah, but then anytime I want an updated executable, I have to do that :/
Any way to do it better?
Steven

Did you ever wonder why we had to run for shelter when the promise of a brave new world unfurled beneath the clear blue sky?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #37
Put it in a Makefile!
Quote this message in a reply
Member
Posts: 370
Joined: 2002.04
Post: #38
I haven't really used makefiles, and the size of my project doesn't seem to really warrant learning it. I've decided to alias it to something like occ.
Steven

Did you ever wonder why we had to run for shelter when the promise of a brave new world unfurled beneath the clear blue sky?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #39
It's always worth having a makefile.
Quote this message in a reply
Member
Posts: 370
Joined: 2002.04
Post: #40
Really? Why?

Did you ever wonder why we had to run for shelter when the promise of a brave new world unfurled beneath the clear blue sky?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #41
Because even when you've only got one source file, it's quicker to type make than it is to type gcc -g -c -Wall -W -Wno-unused-parameter -Werror -Os -I/usr/X11R6/include main.c; gcc -o Executable main.o -L/usr/X11R6/lib -lGL -lGLU -lglut -lX11 -lm, and when you've got more than one file keeping track of dependencies and what needs to be rebuilt makes such a huge improvement to compile times that it's pointless to avoid the makefile...
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Unholy method to link Linux library? Cochrane 3 3,131 Jun 30, 2008 06:37 AM
Last Post: OptimisticMonkey
  Linux geek wanting to get into Mac games programming supenguin 8 5,080 Nov 16, 2005 09:49 PM
Last Post: EvolPenguin
  porting linux glut code to mac os x zynek 12 6,343 Jan 23, 2005 05:47 PM
Last Post: zynek
  Linux Games/Tibia Kris 3 4,503 Sep 27, 2004 04:08 PM
Last Post: ERaZer
  Linux IDE's wadesworld 5 4,850 Jul 20, 2004 08:17 AM
Last Post: Iron Wallaby