Linking libsrtp problems - c

I installed libsrtp on my ubuntu machine according to the directives in read me, the tests worked fine, and the rptw utility included in libsrtp worked perfectly too. But when I tried to include srtp.h in my HelloWorld! program, it gives me an error that:
fatal error: srtp.h: No such file or directory
compilation terminated.
Concretely, my main file is this
#include "srtp.h"
int main()
{
return 0;
}
My libsrtp.a is present in /usr/local/lib/lib
I used this gcc statement from this blog:
gcc -static main.c -L/usr/local/lib/lib/ -llibsrtp -o main
I will be deeply grateful for any help.

You've found your libsrtp.a , but where is srtp.h ? You'll need to tell the compiler where to search for included files if it's not in a standard location with the -I flag.
Perhaps you need a -I/usr/local/include or -I/usr/local/include/srtp
Note also that -llibsrtp is likely wrong, you need to give the name without the lib prefix. So that makes it -lsrtp

Related

GCC compiler cannot find stdio.h

OS - Windows.
I'm using a MinGW compiler. When trying to compile a simple program:
#include <stdio.h>
int main()
{
printf("Hello, world\n");
}
through the console command:
gcc.exe -g (filedir) -o (filedir.obj)
an error message comes up, saying "no include path in which to find stdio.h".
How do I make the compiler find the header and compile the program?
Use the -I option to specify additional include paths as part of the gcc command:
gcc -I /include/file/directory ...
Having said that, you should not need to specify an additional include path to find stdio.h (or any other standard library header). Review how you installed MinGW and make sure you followed all the instructions correctly; you may need to uninstall and re-install.
I solved it. My problem was that I had two C compilers installed at the same time, the other one came along with Free Pascal. Found it out through checking every folder in my Path environment variable. Thanks for the replies.

How to use shared object file in c compilation

I'm trying to use this C library using gcc Apple LLVM version 8.0.0 (clang-800.0.42.1) on macOS Sierra. I've done the following steps:
make libquirc.so
Copied libquirc.so into my project directory
gcc -o quirc_test quirc_test.c -L. -l libquirc.so.1.0
It produces the error:
quirc_test.c:1:10: fatal error: 'quirc.h' file not found
#include <quirc.h>
^
1 error generated.
quirc_test.c
#include <quirc.h>
This is the first time I've tried to do anything in C and other related questions about compiling with the link flag didn't seem to help as seen above.
C is somewhat primitive. Shared object libraries do not contain the declaration of the API they implement - at least not in enough detail or a form that the compiler can understand.
You'll need the header file quirc.h somewhere you can find it. You could just copy it into the current directory just like the library, but you'll need a minor adjustment to the include statement.
#include "quirc.h"
If the included file is surrounded by double quotes instead of angle brackets, it will first look in the source code directory instead of the system header directories.
An alternative is to install the library somewhere e.g. /usr/local. Your library would go in /usr/local/lib nd your header in /usr/local/include. If you do that, use the -I directive on the compiler command line to tell the compiler where to look for the header e.g.
cc -I/usr/local/include -L/usr/local/lib -lquirc quirc_test.c

Compile error when using FFMPEG library

I have tried to compile a C program using FFMPEG but every time I compile it fails at the include statement:
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
Gcc provides this error message:
libavcodec/avcodec.h: No such file or directory
I have installed FFMPEG and created the shared libraries, but when I try to link those libraries when I compile I get the same error.
gcc main.c -L ffmpeg_build/lib -l ffmpeg_build/include/libavcodec/avcodec.h
Do I get this error because I am linking the library incorrectly, or is there some other issue?
This is the first time I am using someone else's library, so please excuse me if I am asking a silly question.
A lowercase -l is a linker option used to specify libraries. They might look like libsomething.a and becomes -lsomething in the linker invocation. In order to add a directory to the header search path, use a capital i, -I.
gcc main.c -L/some/path/ffmpeg_build/lib -I/some/path/ffmpeg_build/include

GCC compiler is unable to find pcre.h

I am trying to compile a C program which uses regexes on FreeBSD. I have checked in /usr/local/include and the file pcre.h is definitely there.
However, no matter what I do, I get the following compiler error:
/usr/home/myname/project/include/pcre_wrap.h:4:18: error: pcre.h: No such file or directory
What could be going wrong? My understanding of C libraries on Unix could be better...
As the comment above says you need to use #include. If this isn't working you may want to export an environment variable C_INCLUDE_PATH that points to the header file.
Failing that why not try adding -I/usr/local/include to your gcc call, something like gcc myfile.c -I/usr/local/include -o myexe

Still get 'curl/curl.h: No such file or directory' in spite of all looks proper

I installed on windows curl 7.28.0 from curl-7.28.1-devel-mingw32.zip through minGW console to default directory like:
./config && make && make install
All needed headers (aka curl.h, types.h ...) I see in C:\MinGW\msys\1.0\local\include\curl
libcurl.pc placed in C:\MinGW\msys\1.0\local\lib\pkgconfig\
libcurl.a, libcurl.dll.a and libcurl.la placed in C:\MinGW\msys\1.0\local\lib.
My download_file.c file includes are:
...
#include <curl/curl.h>
#include <curl/types.h>
#include <curl/easy.h>
...
I try to compile the C code with followed command through gcc:
$ gcc -IC:/MinGW/msys/1.0/include/
-IC:/MinGW/msys/1.0/local/include/curl
-IC:/MinGW/msys/1.0/local/lib/pkgconfig
-o download_file download_file.c -llibcurl -lcurl
with absolute path get the same error:
gcc -I/include/
-I/local/include/curl
-I/local/lib/pkgconfig
-o download_file download_file.c -llibcurl -lcurl
But I still get an error:
download_file.c:21:23: fatal error: curl/curl.h: No such file or directory compilation terminated.
row 21 is #include <curl/curl.h>
What I did wrong? Please help.
You have the curl/ directory in the source code, but also in the option.
It seems the option should point out the higher-level directory in which curl/ is, so it should be something like:
-I/local/include/
I think the problem is likely that you give your include paths on the command line in the Win32 path format. This is not the same as the one used by msys (or ultimately Cygwin).
Try these:
$ gcc -I/include/
-I/local/include/curl
-I/local/lib/pkgconfig
...
Hope I got the absolut paths right, but you can check in your msys shell.
What ticked me off was that you use ./config, which wouldn't work from the Command Prompt, but works from the msys shell. So you need to give paths that all the programs in MinGW understand.
Basically, most programs in MinGW only have the concept of a single file system root, like on any unixoid system, while Win32 has multiple (the drive letters). Since the MinGW programs are linked accordingly, you need to give paths that they understand.
Thank you very much to #0xC0000022L and #unwind. By your help I fixed my problem.
0xC0000022L you are right about absolute path
unwind you are right about -I/local/include/ instead -I/local/include/curl
I found other problem: -L/local/lib instead -I/local/lib.
So this is a working command:
gcc -I/include/
-I/local/include
-L/local/lib
-o download_file download_file.c -llibcurl -lcurl

Resources