User Name
Password
AppleNova Forums » Programmer's Nook »

Xcode passing wrong flags to gcc


Register Members List Calendar Search FAQ Posting Guidelines
Xcode passing wrong flags to gcc
Thread Tools
Banana
is the next Chiquita
 
Join Date: Feb 2005
 
2009-05-16, 18:45

After fooling about with command line gcc and getting some success with compiling some C files, I decided to try it out on Xcode. However, Xcode seems bent on passing flag -dynamiclib when I want to pass another incompatible flag -bundle_loader. I've looked everywhere in the Xcode but can't find any setting that would set the project to be compiled with the unwanted -dynamiclib flag.

From the command line, I'd pass this command:

Code:
bash-3.2$ gcc -Wall -bundle -bundle_loader /usr/local/mysql/bin/mysqld -o my_udf.so `/usr/local/mysql/bin/mysql_config --cflags` My_UDF.c
(the mysql_config resolves to this:
Code:
-I/usr/local/mysql/include/mysql -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT -DDONT_DECLARE_CXA_PURE_VIRTUAL
)


In XCode, I placed the include path in "Header Search Paths", the path to mysqld for "Bundle_Loader", and the rest of flags as shown in "Other C Flags". This let me compile the C file successfully, but when I try to build the file, Xcode complains that -bundle_loader isn't allowed with -dynamiclib.

I've already tried to untick some options such as "Link Shared Library" or something similar to no avail. Searching the properties turns nothing for dyn* and lib* or flags.

What am I missing?
  quote
RobUSVI
Member
 
Join Date: May 2007
 
2009-05-17, 18:00

Can you paste the actual GCC command issued by XCode? You can get it from build results window... it is the center view, but is only shown if you click the little icon that looks like morse code (or tiny lines of text)
  quote
ShadowOfGed
Travels via TARDIS
 
Join Date: Aug 2005
Location: Earthsea
 
2009-05-22, 23:10

Quote:
Originally Posted by Banana View Post
After fooling about with command line gcc and getting some success with compiling some C files, I decided to try it out on Xcode. However, Xcode seems bent on passing flag -dynamiclib when I want to pass another incompatible flag -bundle_loader. I've looked everywhere in the Xcode but can't find any setting that would set the project to be compiled with the unwanted -dynamiclib flag.

From the command line, I'd pass this command:

(snip)

In XCode, I placed the include path in "Header Search Paths", the path to mysqld for "Bundle_Loader", and the rest of flags as shown in "Other C Flags". This let me compile the C file successfully, but when I try to build the file, Xcode complains that -bundle_loader isn't allowed with -dynamiclib.

I've already tried to untick some options such as "Link Shared Library" or something similar to no avail. Searching the properties turns nothing for dyn* and lib* or flags.

What am I missing?
What are you trying to do? I'm 99% sure these are flags you should never need to use. Best I can tell, the ONLY use for -bundle_loader is as a linker argument for plugin bundles. However, nobody uses MH_BUNDLE anymore; it might as well be deprecated.

You want a dynamic library, and don't need to futz with these other settings. Where have you been getting these flags / suggestions?

EDIT: Bundles are absolutely not what you're building here. On Mac OS X, the extension is ".dylib", but even with .so you're making a dynamic library. A bundle is contained in a directory, i.e. MyFancy.plugin/Contents/MacOS/MyFancy.

Apparently I call the cops when I see people litter.
  quote
Banana
is the next Chiquita
 
Join Date: Feb 2005
 
2009-05-23, 00:01

Hey, RobUSVI- thanks for posting and apologies for not posting back- I had lost track.

However, I had later found the answer lies in setting Mach-O type to "Bundle" to get rid of that error from conflicting flags being passed. I tried your suggestion but didn't get anything that resembled a command to gcc; it was usually passed to libtool instead.

ShadowOfGed, I got this from this when I was having problems with loading the library. I can compile it successfully as a dynamic library but it just doesn't get loaded whereas bundle seems to work.
  quote
ShadowOfGed
Travels via TARDIS
 
Join Date: Aug 2005
Location: Earthsea
 
2009-05-23, 02:14

Quote:
Originally Posted by Banana View Post
Hey, RobUSVI- thanks for posting and apologies for not posting back- I had lost track.

However, I had later found the answer lies in setting Mach-O type to "Bundle" to get rid of that error from conflicting flags being passed. I tried your suggestion but didn't get anything that resembled a command to gcc; it was usually passed to libtool instead.

ShadowOfGed, I got this from this when I was having problems with loading the library. I can compile it successfully as a dynamic library but it just doesn't get loaded whereas bundle seems to work.
But you're lying to Xcode: you're not building a bundle. That binary is not in a bundle. If you get link errors because you reference a symbol in the MySQL binary, what you want to add is this:

Code:
-undefined dynamic_lookup
To your link command in some capacity. If you're linking with GCC, that's "-Wl,-undefined,dynamic_lookup". This will allow your code to link, and cause it to properly bind when MySQL loads your object. However, be aware that it will let you mistakenly use any undefined symbol.

Apparently I call the cops when I see people litter.
  quote
Posting Rules Navigation
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Post Reply

Forum Jump
Thread Tools
Similar Threads
Thread Thread Starter Forum Replies Last Post
You've got to be kidding me...another Six Flags "hat retrieval" goes wrong psmith2.0 AppleOutsider 32 2008-09-04 23:10
Tragic Passing.... Yontsey AppleOutsider 25 2008-08-21 14:55
Teen decapitated by ride at Six Flags Over Georgia PKIDelirium AppleOutsider 82 2008-07-02 23:09
Profile Flags Fahrenheit Feedback 77 2008-04-17 19:06
PHP : Passing declared variables to REQUIRE'd files. drewprops Genius Bar 9 2005-01-11 00:03


« Previous Thread | Next Thread »

All times are GMT -5. The time now is 15:36.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004 - 2024, AppleNova