LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Can't compile Linsched on Arch, ld cannot find -lrt and -lpcre (https://www.linuxquestions.org/questions/linux-software-2/cant-compile-linsched-on-arch-ld-cannot-find-lrt-and-lpcre-4175485120/)

Gaidal 11-19-2013 04:49 AM

Can't compile Linsched on Arch, ld cannot find -lrt and -lpcre
 
I'm trying to compile Linsched, and keep getting the following error:

Code:

CC UNIX_TEST unix-mcarlo-sim
/usr/bin/ld: cannot find -lrt
/usr/bin/ld: cannot find -lpcre
collect2: error: ld returned 1 exit status

What the Makefile is trying to do here is:
Code:

${UNIX_TESTS}: ${OBJ_FILES} $$@.o
    @echo CC UNIX_TEST $@
    @${LD_PERCPU} -o $@.percpu $^
#two definitions of mktime
    @${CC} -Wl,--allow-multiple-definition -static -o $@ $@.percpu -lrt -lm -lpcre

I have librt.so and libpcre.so in /usr/lib. My ld.so.conf is empty, but I think /usr/lib should be searched anyway.

Some threads seemed to imply that I need some headers too, and I do have pcre.h under /usr/include, but I don't see why I'd need this just to compile with -lrt and -lpcre.

What am I missing here?

jpollard 11-19-2013 05:15 AM

You need headers to define the function parameters for the C compiler so that it knows
how to check for type errors, and improper use of return values.

Even then, if your system is a 64 bit system, then you need 64 bit libraries.

/lib is for 32 bit libraries, thus the system won't find them unless you are linking a 32 bit binary.

/lib64 is for 64 bit libraries...

And then you really should put the distribution kit somewhere other than the system directories... things could get damaged during updates to the system. I usually put them in /usr/local, then the /etc/ld.so.conf.d directory would have an entry to refer to /usr/local/lib64 (or lib) so that links can find it.

Gaidal 11-19-2013 06:02 AM

I think Arch Linux is pure 64-bit (unless you enable multilib), and I have:
Code:

lib64 -> usr/lib/
So that's probably not the issue.

By the way I have linked -lrt in my own projects so I know it's there. Just don't understand what's different about this Makefile.

My directories are just the Arch Linux defaults, and haven't given me any trouble during the years I've used it.

Gaidal 11-19-2013 08:06 AM

Because the -static flag was specified, ld was looking not for .so-files but for librt.a and libpcre.a, which I didn't have.

Since I'm not sure how to get these static versions that I couldn't in the repo, I solved the problem by removing "-static" in the makefile above.


All times are GMT -5. The time now is 11:23 AM.