/usr/bin/ld: cannot find [...] when compiling

Поиск
Список
Период
Сортировка
Искать

/usr/bin/ld: cannot find [...] when compiling

От:
"Janek Sendrowski" <janek12@web.de>
Дата:
Hi,

 

My Makefile looks like this:


PROGRAM = test
DATA = test.c
PG_CONFIG = pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)

 


The file test.c only includes the postgres.h (#include "postgres.h"), but I get this error, when compiling:

/usr/bin/ld: cannot find -lxslt
/usr/bin/ld: cannot find -lxml2
/usr/bin/ld: cannot find -lpam
/usr/bin/ld: cannot find -ledit
collect2: ld returned 1 exit status
make: *** [test] Error 1

 

Does anyone have an idea?

 

Janek Sendrowski

Re: /usr/bin/ld: cannot find [...] when compiling

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
"Janek Sendrowski"  writes:
> 
The file test.c only includes the postgres.h (#include "postgres.h"), but I get this error, when compiling:
>
/usr/bin/ld: cannot find -lxslt
> /usr/bin/ld: cannot find -lxml2
> /usr/bin/ld: cannot find -lpam
> /usr/bin/ld: cannot find -ledit
> collect2: ld returned 1 exit status
> make: *** [test] Error 1
[ please don't post html-only mail to the PG lists ] Where did you get your Postgres installation from? It looks like it was configured to be built with a bunch of libraries that you don't have installed, so I'm guessing it wasn't self-built. The path of least resistance would be to install libxslt-devel, libxml2-devel, pam-devel, libedit-devel, etc (or whatever those packages are named on your platform), so as to match the build environment that the Postgres package is expecting. regards, tom lane

Re: /usr/bin/ld: cannot find [...] when compiling

От:
"Janek Sendrowski" <janek12@web.de>
Дата:
Hi,

Thanks for your answer.
Now the link editor is working, but I still have one problem.
The files in /utils for example include there files with #include "utils/filename" and it doesn't work, because the file which includes them is already in the directory /utils.
It's the same with all directories...
Sorry, if this question is to silly, but what do I wrong?

Janek Sendrowski

Re: /usr/bin/ld: cannot find [...] when compiling

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
"Janek Sendrowski"  writes:
> Now the link editor is working, but I still have one problem.
> The files in /utils for example include there files with #include "utils/filename" and it doesn't work, because the file which includes them is already in the directory /utils.

Could we see the exact code you're writing and the output of the "make"
attempt?  (That is, I want to see both the gcc call and the error
message.)  It should "just work", and you're not providing nearly
enough information to guess at what's wrong.

			regards, tom lane

Re: /usr/bin/ld: cannot find [...] when compiling

От:
"Janek Sendrowski" <janek12@web.de>
Дата:
The file test.c just inlcudes: #include "postgres.h".

root@ubuntu:/usr/include/postgresql/9.3/server# gcc test.c
In file included from postgres.h:48:0,
                 from test.c:1:
utils/elog.h:69:28: fatal error: utils/errcodes.h: No such file or directory
compilation terminated.

If elog.h file only includes "errcodes.h" without /utils, it's working.
It's the same With all files I'm including.

Makefile: 
PROGRAM = test
DATA = test.c

PG_CONFIG = pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)

root@ubuntu:/usr/include/postgresql/9.3/server# make
gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -fPIC -pie -I/usr/include/mit-krb5 -DLINUX_OOM_ADJ=0 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -g   -L/usr/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -L/usr/lib/mit-krb5 -L/usr/lib/i386-linux-gnu/mit-krb5 -L/usr/lib/i386-linux-gnu  -Wl,--as-needed  -lpgport -lpgcommon -lxslt -lxml2 -lpam -lssl -lcrypto -lkrb5 -lcom_err -lgssapi_krb5 -lz -ledit -lcrypt -ldl -lm  -o test
/usr/bin/ld: cannot find -lxslt
/usr/bin/ld: cannot find -lxml2
/usr/bin/ld: cannot find -lpam
/usr/bin/ld: cannot find -ledit
collect2: ld returned 1 exit status
make: *** [test] Error 1

I don't know where to get these devel-packages.
Could I just reinstall the postgresql-server-dev-9.3 package?

Janek Sendrowski

Re: /usr/bin/ld: cannot find [...] when compiling

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
"Janek Sendrowski"  writes:
> The file test.c just inlcudes: #include "postgres.h".
> root@ubuntu:/usr/include/postgresql/9.3/server# gcc test.c
> In file included from postgres.h:48:0,
>                  from test.c:1:
> utils/elog.h:69:28: fatal error: utils/errcodes.h: No such file or directory
> compilation terminated.

> If elog.h file only includes "errcodes.h" without /utils, it's working.
> It's the same With all files I'm including.

> Makefile: 
> PROGRAM = test
> DATA = test.c

> PG_CONFIG = pg_config
> PGXS := $(shell $(PG_CONFIG) --pgxs)
> include $(PGXS)

> root@ubuntu:/usr/include/postgresql/9.3/server# make
> gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -fPIC -pie -I/usr/include/mit-krb5 -DLINUX_OOM_ADJ=0 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -g   -L/usr/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -L/usr/lib/mit-krb5 -L/usr/lib/i386-linux-gnu/mit-krb5 -L/usr/lib/i386-linux-gnu  -Wl,--as-needed  -lpgport -lpgcommon -lxslt -lxml2 -lpam -lssl -lcrypto -lkrb5 -lcom_err -lgssapi_krb5 -lz -ledit -lcrypt -ldl -lm  -o test

It looks like the problem is that there aren't any Postgres-specific -I
flags in the make command.  After a bit of poking around in the pgxs code
I think the reason why not is that you're using the PROGRAM target instead
of MODULES or MODULE_big.  This might be a bug in our makefiles, but it's
also somewhat defensible, in that if you're building a standalone program
then you aren't going to have access to any server internal functions.

What's your actual goal here --- are you trying to build a server
extension or a standalone program?  If the former, you should be using the
MODULES or MODULE_big targets.  If the latter, you should probably be
including postgres_fe.h not postgres.h.

> /usr/bin/ld: cannot find -lxslt
> /usr/bin/ld: cannot find -lxml2
> /usr/bin/ld: cannot find -lpam
> /usr/bin/ld: cannot find -ledit
> collect2: ld returned 1 exit status
> make: *** [test] Error 1

> I don't know where to get these devel-packages.

Since you let slip that you're using ubuntu, they probably have names
ending in -dev not -devel.

			regards, tom lane

Re: /usr/bin/ld: cannot find [...] when compiling

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
I wrote:
> "Janek Sendrowski"  writes:
>> Makefile: 
>> PROGRAM = test
>> DATA = test.c

> It looks like the problem is that there aren't any Postgres-specific -I
> flags in the make command.  After a bit of poking around in the pgxs code
> I think the reason why not is that you're using the PROGRAM target instead
> of MODULES or MODULE_big.

No, wait, I take that back.  The problem with this makefile is you
need to say 
OBJS = test.o
in order to tell the makefile what files PROGRAM is built from.  It seems
pretty unlikely that "DATA = test.c" is what you want, either.

Having said that, I'm still not sure that PROGRAM is really the final
target you want.

			regards, tom lane

Re: /usr/bin/ld: cannot find [...] when compiling

От:
"Janek Sendrowski" <janek12@web.de>
Дата:
Now it's working.
My Makefile:

OBJS = test.o
MODULES = test
DATA = test.c

PG_CONFIG = pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)

Is it possible to execute the code just like this?
I like to do that for Debugging.
I can't execute the .so files, of course and If I just do "gcc filename", I have the issue with the includes.

Janek Sendrowski

Re: /usr/bin/ld: cannot find [...] when compiling

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
"Janek Sendrowski"  writes:
> Is it possible to execute the code just like this?
> I like to do that for Debugging.
> I can't execute the .so files, of course and If I just do "gcc filename", I have the issue with the includes.

No, if it's a backend extension there's no way to execute it standalone.

			regards, tom lane

FAQ