Skip navigation.
 
mlRe: Cocoa Database Connection
FROM : Justin Giboney
DATE : Mon Mar 24 22:06:58 2008

Putting this line

-L/usr/local/pgsql/lib -lpq

in my Other Linker Flags, made the error go away,

thanks Tony, thanks everyone else who was working with me

Justin Giboney


On Mar 24, 2008, at 2:57 PM, Tony Becker wrote:

> Seems like
>
> -L/usr/local/pgsql/lib -lqp
>
> or
>
> -L/usr/local/pgsql/lib -lqp
>
> Should work, from your file names.
>
> It also seems like including <libpg.h> might be better then <libpq-
> fe.h>, but I don't know what the -fe means.
> There also maybe (should be) an include file named pq.h -> by 
> convension the include <name.h> is the same as -l<name> for 
> libraries, so include <libpq.h> seems strange to me.
>
> It seems like the progress sql guy replied in the thread - he may 
> have a better answer.
>
> On Mar 24, 2008, at 4:36 PM, Justin Giboney wrote:
>

>> Tony,
>>
>> I have the following files that the search returns
>>
>> /usr/local/src/postgres/postgres-8.3.0/src/include/libpq/libpq-fe.h
>> /usr/local/src/postgres/postgres-8.3.0/src/interfaces/libpq/libpq-
>> int.h
>> /usr/local/src/postgres/postgres-8.3.0/src/include/libpq/libpq-be.h
>> /usr/local/src/postgres/postgres-8.3.0/src/include/libpq/libpq-fs.h
>> /usr/local/src/postgres/postgres-8.3.0/src/include/libpq/libpq.h
>>
>> /usr/local/pgsql/include/libpq-fe.h  --this is the file I included
>> /usr/local/pgsql/lib/libqp.a
>> /usr/local/pgsql/lib/libpq.dylib

>
>     are these last two lines really backwards pq vs qp?

>>
>>
>> I tried the ones that seemed the most logical. The had compile 
>> errors.
>>
>> Justin Giboney
>>
>>
>> On Mar 24, 2008, at 1:54 PM, Tony Becker wrote:
>>

>>> Yes, it's always a guess.
>>> First, try
>>>     -lpq-fe
>>> to match the header include.
>>>
>>> Next, you'll need to look for it.
>>>
>>> Try searching for a file named libpq in the finder - "This mac" 
>>> and "file name"
>>> When you find it, also try -L<path to library directory> -l<lib 
>>> name minus "lib" in front and .extension> in the "Other linker 
>>> Flags"
>>>
>>> Might be something like:
>>>
>>>     -L/usr/local/lib -lpq-fe
>>>
>>>
>>>
>>>
>>>
>>> On Mar 24, 2008, at 3:46 PM, Justin Giboney wrote:
>>>

>>>> Thank you for responding,
>>>>
>>>> All I have is the "include" folder that came with postgresql. I 
>>>> am not sure what I need to add to that line
>>>>
>>>> I tried:
>>>> -lpq
>>>> -llibpq
>>>> -l<libpq>
>>>> -l<pq>
>>>>
>>>> Xcode just gives me a
>>>> Command /Developer/usr/bin/gcc-4.0 failed with exit code 1
>>>> when I try to compile
>>>>
>>>> *I figured that the brackets were not need, but i tired them 
>>>> anyways
>>>>
>>>>
>>>> On Mar 24, 2008, at 1:35 PM, Tony Becker wrote:
>>>>

>>>>> You also need to link to the library.
>>>>> I'll assume you have a development library installed, since you 
>>>>> have a header.
>>>>> You need to add a -l<library> (with the correct name/syntax of 
>>>>> the library (strip the preceding "lib" and trailing extension of 
>>>>> whatever it is) flag to the "Other Linker Flags" of the "Build" 
>>>>> tab of the target application (right click the target 
>>>>> application and "get info")
>>>>> There, that was easy 8-)
>>>>>
>>>>> On Mar 24, 2008, at 3:21 PM, Western Botanicals wrote:
>>>>>

>>>>>> Thank you to everyone who has responded so far. I ended up 
>>>>>> fixing the problem by importing the "postgres_ext.h" file into 
>>>>>> my project (I wish I could have just done a find for it).
>>>>>>
>>>>>> But now with the following code:
>>>>>>
>>>>>> #import <Cocoa/Cocoa.h>
>>>>>> #include <libpq-fe.h>
>>>>>>
>>>>>> int main(int argc, char *argv[])
>>>>>> {
>>>>>>     char *conninfo = "";
>>>>>>     PGconn    *conn;
>>>>>>
>>>>>>     conn = PQconnectdb(conninfo);
>>>>>>
>>>>>> return NSApplicationMain(argc,  (const char **) argv);
>>>>>> }
>>>>>>
>>>>>> I get the following error when I try to compile:
>>>>>>
>>>>>> "_PQconnectdb", referenced from:
>>>>>> _main in main.o
>>>>>> symbol(s) not found
>>>>>> collect2: ld returned 1 exit status
>>>>>>
>>>>>> Is this code incorrect, or do I need to import something else?
>>>>>>
>>>>>> Thank you,
>>>>>>
>>>>>> Justin Giboney
>>>>>> _______________________________________________
>>>>>>
>>>>>> Cocoa-dev mailing list (<email_removed>)
>>>>>>
>>>>>> Please do not post admin requests or moderator comments to the 
>>>>>> list.
>>>>>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>>>>>
>>>>>> Help/Unsubscribe/Update your Subscription:
>>>>>> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
>>>>>>
>>>>>> This email sent to <email_removed>

>>>>>

>>>>

>>>

>>

>

Related mailsAuthorDate
mlCocoa Database Connection Justin Giboney Mar 21, 23:33
mlRe: Cocoa Database Connection Justin Giboney Mar 22, 00:50
mlRe: Cocoa Database Connection Jason Stephenson Mar 22, 01:34
mlRe: Cocoa Database Connection Jeff LaMarche Mar 22, 01:37
mlRe: Cocoa Database Connection Western Botanicals Mar 24, 20:21
mlRe: Cocoa Database Connection Jeff LaMarche Mar 24, 20:54
mlRe: Cocoa Database Connection Justin Giboney Mar 24, 22:06
mlRe: Cocoa Database Connection Jens Alfke Mar 25, 04:25
mlRe: Cocoa Database Connection Andrew Satori Mar 26, 21:12