LinuxForum.Fans
Тема

Вопросы по компилятору и линковщику

Автор: skif2008 4 сообщений 1225 просмотров
#100357

есть файл в котором используется такой код

#include <path/file.h>

как определяется полный путь к file ?
как его переопределить (кроме как #include </fullpath/file.h>) ?

в командной строке есть -lssl
похоже, что библиотека берется /usr/lib/libssl.a
также надо переопеределить путь
и еще вопрос откуда взялся префикс lib в имени libssl.a ?
как указать линкеру библиотеку, если у нее имя вида abc.a ?
спасибо

#100415
skif2008 написал:
есть файл в котором используется такой код

#include <path/file.h>

как определяется полный путь к file ?

--sysroot=dir
Use dir as the logical root directory for headers and libraries. For example, if the compiler would
normally search for headers in /usr/include and libraries in /usr/lib, it will instead search
dir/usr/include and dir/usr/lib.

т.е. без этой опции к файлу добавляется /usr/include для вкл. файлов, и /usr/lib для либ.

skif2008 написал:
в командной строке есть -lssl
похоже, что библиотека берется /usr/lib/libssl.a
также надо переопеределить путь

-llibrary
-l library
Search the library named library when linking. (The second alternative with the library as a separate
argument is only for POSIX compliance and is not recommended.)

It makes a difference where in the command you write this option; the linker searches and processes
libraries and object files in the order they are specified. Thus, foo.o -lz bar.o searches library z
after file foo.o but before bar.o. If bar.o refers to functions in z, those functions may not be
loaded.

The linker searches a standard list of directories for the library, which is actually a file named
liblibrary.a. The linker then uses this file as if it had been specified precisely by name.

The directories searched include several standard system directories plus any that you specify with
-L.

Normally the files found this way are library files---archive files whose members are object files.
The linker handles an archive file by scanning through it for members which define symbols that have
so far been referenced but not defined. But if the file that is found is an ordinary object file, it
is linked in the usual fashion. The only difference between using an -l option and specifying a file
name is that -l surrounds library with lib and .a and searches several directories.

в самом конце написано, что да, действительно прибавляется libssl.a

#100421

только зачем?!
можно ведь писать:

text
#include "myincludefile.h"

А свои либы можно добавить уже на стадии линковки (см man ld).
Зачем так-то делать?

#101253
drBatty написал:
только зачем?!
можно ведь писать:
text
#include "myincludefile.h"

А свои либы можно добавить уже на стадии линковки (см man ld).
Зачем так-то делать?

А если у мну в проекте две локальные директории с хидерами? В этом случае

text
#include "myincludefile.h"

не спасет...

Войдите или зарегистрируйтесь, чтобы ответить.