header files not found, Eclipse - c

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"?

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.

Build commands needed to run Wine programs from IDE

I’ve recently done a git clone of the wine repository at https://github.com/wine-mirror/wine and downloaded the folders to (~/repo/wine/). I'm trying to run Notepad, but don't know how. I am assuming that to build and compile it, I would need to run main.c from the notepad folder. I’m running GCC v 8.3.0 on Raspbian/Linux 10
With the repo downloaded as shown above, what build commands would I need to run notepad’s main.c from Geanie (or any, currently using Geanie) IDE? Can a single compile and/or build command let me run notepad from Geanie, or am I missing something?
Other details (not needed if what I thought I was going to do can't be done):
I wanted to try to run main.c at (~/repo/wine/programs/main.c), but don’t know how to get GCC to view all of the necessary header files. In my execution instructions window in Geanie, I have
gcc -Wall -c “%f” /home/pi/repo/wine/include
and my build instruction (it won't compile, so this isn't anything I've even gotten to work with yet...)
gcc -Wall -o “%e” “%f” /home/pi/repo/wine/include
When I attempt to compile, I get:
Stdio.h:11:10: fatal error: corecrt_wstdui.h: No such file or directory.
#include <corecrt_wstudio.h>
I went over to the stdio.h and attempted to add a build instruction here as well that also targets the include folder (which is the supposedly missing file), but it won’t compile.
Using cpp -v, I can see my include paths for GCC are as follows:
#include”...” paths:
#include<...> paths:
\usr\lib\gcc\arm-linux-gnueabihf\8\include
\usr\local\include
\usr\lib\gcc\arm-linux-gnueabihf\8\include-fixed
\usr\include\arm-linux-gnueabihf
\usr\include

How to compile the LIBVLC example code on windows using gcc

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;

using i686-w64-mingw32-g++ for static libraries

I have a JNI project, which I have to make work on Windows (I am working on Linux). This project actually depends on third-party library file which is static (archived i.e .a files). I am trying to create a JNI shared library file using i686-w64-mingw32-g++ and including -static followed by static third-party library name. Following is the command I am using
i686-w64-mingw32-g++ -v -L./ -L/home/user/jre1.8.0_40/lib/amd64/ -I/user/all/apps/Linux2/x86_64/gcc/4.8.2/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.8.2/include -shared -o test.dll test.cpp -lstdc++ -static -thirdparty
In-spite of placing the third party library in the current working directory, I keep getting error
/user/all/apps/Linux2/src/mxe/2013_12_03/usr/bin/../lib/gcc/i686-w64-mingw32/4.8.1/../../../../i686-w64-mingw32/bin/ld: cannot find -thirdparty
Please note : I included -I/user/all/apps/Linux2/x86_64/gcc/4.8.2/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.8.2/include to avoid the error cannot find jni.h which I hit before including the path.
I also tried to compile using gcc, in place of g++.
Do I need to create .dll of this third-party library(currently it is archived .a containing .obj files)?
Being a newbie in cross compilers, I might be doing something wrong. Please correct me and any suggestions with this will be very helpful. Thank you.
-Wl,--export-all-symbols -Wl,--add-stdcall-alias -v adding this solved my problem

Makefile in Windows

I have a folder named 'X'. In X I have two subfolders: src and include.
The src folder contains a C file main.c, and the include folder contains a file main.h.
I want to write a makefile to build these files(from folder X) in windows command prompt.
I have tried a lot but with no effect.
First of all I need the make file format in Linux for this, and once I have that i will do that in Windows.
Can anybody help me in doing this?
Try the following links, in there you'll find the format, and basically all that you need to build your Makefile:
http://mrbook.org/blog/tutorials/make/
http://www.opussoftware.com/tutorial/TutMakefile.htm
http://oucsace.cs.ohiou.edu/~bhumphre/makefile.html
Once you've made your Makefile, you can use MinGW's mingw32-make - A Windows native build of GNU make.
Open the folder (X) in file explorer.
Right click anywhere > new > text document.
Right click on the file > rename > remove .txt extension.
Open up the makefile with your favorite text editor.
You can use NMake, which is the windows alternative do Linux make. It is a command-line tool included with Visual Studio.
Although the syntax is very similar, you will find some differences. So the makefile that works on Linux may not work directly with NMake in windows.
In Linux, these lines for example:
gcc -c main.cpp -o main.o
gcc -o app main.o -lstdc++
In Windows, probably should be changed to:
cl.exe /c main.cpp /Fomain.o
link.exe /OUT:app.EXE main.o
So the makefile require edition to work with NMAKE in windows.
To use the makefile "as is", you should try a tool to mimic Linux commands in Windows, like Cygwin.

Resources