How to compile the LIBVLC example code on windows using gcc - c

I want to build the libvlc example (https://wiki.videolan.org/LibVLC_Tutorial) so i downloaded the sources and also copied libvlc.dll and libvlccore.dll (from my vlc installation) into the current directory. Then i try to compile it by issuing
gcc example.c -o example -I./include -L./lib -L./ -llibvlc
but get the error
example.c:3:22: fatal error: vlc/vlc.h: No such file or directory
#include <vlc/vlc.h>
^
I hope this is enough information, i controlled all paths and files twice. Thank you in advance.

you need vlc sdk, not just files from vlc source code ;
you need dll files for your already compiled application, but for build you need .lib files - also part of sdk;
for this you need to build them - for this step refer to https://medium.com/#tobias.strg/compiling-vlc-3-x-in-2020-a390c6a73c24;
no doubt you can use some nigthly builds of vlc (check for zip files with "debug" suffix) https://artifacts.videolan.org/vlc-3.0/nightly-win64/20220420-0220;
after you got sdk pack for your platform you can compile - pointing to headers files from sdk, and linking with libs from sdk;

Related

Why gcc under Windows O.S. produces a .o instead of a .lib file when compiling static libraries?

I am using gcc 8.1.0 on Windows. To install it I set up Code::Blocks on my computer and updated the environment variable list by adding the path to the gcc.exe program within the installation folder of CodeBlocks. The file editor I used was the built-in editor in Visual Studio. The terminal to compile was the power shell from Visual Studio as well.
In the library development folder I have the files mul.c and mul.h. Their content is irrelevant.
To compile the library I use the command:
gcc -c mul.c
When I run it, it creates a file object mul.o and not mul.lib. I needed to use the option -o mul.lib to successfully create the desired extension file. After placing the header, the .lib file and the main.c in the same parent folder I am obvioudly able to build the executable by running.
gcc main.c -I./include -L/static -lmul -o my_program.exe
I have two questions:
Why does gcc produces a .o if I am in a Windows environment?
I followed a tutorial that compile the static library under Linux and it names it libmul.o, in this way the -lmul option is able to retrieve the library. But if I call my generated static library libul.lib it generates the error:
C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-ingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lmul
collect2.exe: error: ld returned 1 exit status
Are these a normal behaviours by gcc, or is it side effect of making gcc available just by updating the Windows environmental variables list?
Thank you to the community in advance.
GCC comes from the *nix world where libraries have the .a extension. When using GCC+MinGW this remains the case.
Shared libraries in MinGW are .dll files but their libraries for linking are .dll.a files.
The advantage of .a files is that a lot of sources build out of the box on Windows with MinGW, especially when using MSYS2 shell.
If you use -l it will look for .a (or .dll.a for shared build) file adding the lib prefix and the extension automatically.
So -lmul will look for libmul.a (static, e.g. when --static linker flag is given) or libmul.dll.a (shared).
By the way, you are using quite an old GCC 8.1.0.
As I write this current version is 12.2.0. Check https://winlibs.com/ for a standalone download (instructions on how to configure in Code::Blocks are on the site) or use MSYS2's package manager pacman.

Linking libraries with a MinGW project in VS code

I am using MinGW version 4.5.2 on windows 10. I am trying to link multiple libraries to a project in VS code. When I try run this command: g++ main.c -o main.exe -I"C:\\Users\\USER\\Programming\\OPenGL Library\\glfw\\include\\glfw3.h" -L"C:\\Users\\USER\\Programming\\OpenGL Library\\glfw\\lib-mingw-w64\\". I get a compile error: main.c:2:24: fatal error: GLFW\glfw3.h: No such file or directory What is wrong with the command above that gives this linking error. As far as I can tell I have pointed MinGW to the library and specified the header file. I am not sure what else I need to add to the command for link the GLFW library as well as other libraries such as GLEW or glm.
If your include directive looks like
#include <GLFW/glfw3.h>
you need to supply a path to a directory which itself contains a directory named GLFW.

Using gcc for compiling/converting, matrix.h: No such file or directory

I'm trying to convert some .c files to R files using gcc.
The files im talking about are circulant.c and circulant.h files located at:
http://www.columbia.edu/~ad3217/fbm.html
There the author also provided short instructions how to do it with gcc.
Things I did so far:
installed Ubuntu via the Win10 Linux Subsystem
installed build essentials
installed gcc
downloaded all meschach files from
http://www.netlib.org/c/meschach/
putting the meschach folder and circulant.x files into one folder and running the command
$gcc -I meschach/ -c circulant.c
gives the error:
In file included from circulant.c:25:0:
circulant.h:11:20: fatal error: matrix.h: No such file or directory
compilation terminated.
I hope that someone with more knowledge with gcc can help me out and point me to a solution.
You aren't using the right header files.
You have some dependency issues you need to take care of first. From the comment header block of circulant.c:
/* This program simulates fractional Gaussian noise or fractional */
/* Brownian motion using the Wood and Chan algorithm. */
/* The C-packages Ranlib and Meschach are used, both available */
/* via Netlib (http://www.netlib.org). */
Looks to me like the missing matrix.h and matrix2.h files are from the meschach library.
You can't just copy the .shar files into a directory.
You need to read the README file and follow the installation instructions. So I would recommend installing the ranlib and meschach dependencies first.

MinGW_w64 missing dll's

I am trying to run a C compiler with Cython in a 64-bit Windows 7 platform.
After having various problems with the C compilers from Visual studio and MinGW32, I tried to install MinGW_w64. I did the following steps :
-I downloaded and extracted winbuilds from http://mingw-w64.org/doku.php/download/win-builds, and I selected the Base GCC package with C support.
-I added C:\PATH_TO_WINBUILDS and C:\PATH_TO_WINBUILDS\bin in the PATH Windows environment variable.
-I wrote helloworld.c, a very simple C program :
#include<stdio.h>
main()
{
printf("Hello World");
}
-Then in cmd I wrote:
gcc helloworld.c -o helloworld.exe
And a dialog box pops out with the following error message :
Impossible to start program because libiconv.dll is missing on your computer. Reinstall program to correct problem.
The dll file does not appear in the lib folder of MinGW_w64. I tried to copy libiconv.a and libiconv.dll.a from the MinGW32 lib folder to the lib folder of MinGW_64, but still no luck.
Any ideas?
You need the DLL file, not the .a link library files. libiconv.dll should exist somewhere in the bin directory. If it is not there, you’ll need to get it from the internet or compile it yourself. Alternatively you could just link statically to the iconv library.
Once you find the DLL, make sure it is in one of the following locations:
* the %PATH%
* the appropriate C:\Windows\system32 or C:\Windows\SysWOW64 directory
* (preferably) next to your executable
I was able to fix the problem by downloading another version on the package on SourceForge.
Thanks!

header files not found, Eclipse

Using eclipse and I am imported an already existing project. Some header files that it is using are located outside the project so it is not able to find them. So I imported the folder (file->import->general->filesystem) where the file is located.
After compiling again, it is still complaining about not finding the header files, so I thought maybe there was a path problem for the compiler. Went to project->properties->c/c++ general->path and symbols, and added the path under the include tab for both the GNU C and GNU C++ entry. That did not solve the issue.
I have noticed the new path I added (host/common/include) does not show up in the gcc command.
Am I not adding it in the right place?
nios2-elf-gcc -xc -MP -MMD -c -I-I -Isrc -I-I -I../../../../../../../fpga_common/include -I-I -I../../../../../../../host/libraries/libbladeRF/include -I../bladeRF_nios_bsp//HAL/inc -I../bladeRF_nios_bsp/ -I../bladeRF_nios_bsp//drivers/inc -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -D'exit(a)=_exit(a)' -DALT_NO_EXIT -DALT_USE_DIRECT_DRIVERS -DALT_NO_INSTRUCTION_EMULATION -DALT_USE_SMALL_DRIVERS -DSMALL_C_LIB -DALT_SINGLE_THREADED -Os -g -Wall -Wextra -Wno-unused-parameter -DBLADERF_NIOS_BUILD -mno-hw-div -mno-hw-mul -mno-hw-mulx -o obj/default/common/src/conversions.o common/src/conversions.c
Any ideas what can be wrong? Or what I have done wrong?
Here's a screen shot of the project window.
Example, Convertion.c includes convertion.h
Files in project window
Solution to problem 1.
There was a make file in the project directory that I needed to add the path to.
Now the problem is it can't find windows.h and intrin.h. Not sure how to fix that yet.
You need to install some depenncies to have the missing headers files:
For windows.h:
In my computer is located at:
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include
It is installed alongside with Visual Studio 2013, so you'll probably need to download some Windows SDK for Windows from Microsoft:
https://developer.microsoft.com/en-us/windows/downloads/windows-8-1-sdk
For intrin.h:
Once again you'll need some external header files:
MinGW has intrin.h but it is called x86intrin.h, so you'll need to replace the header call. See the source with the same problem with you: How to cope with "intrin.h: No such file or directory"?

Resources