freeglut error LNK1104 - linker

In my project I want to use a freeglut library from the unofficial opengl sdk.
I used Premake to generate build files for vs2010. Then I built all libraries (debug). In my project I set Additional Include Directories, Additional Library Directories for the freeglut. In additional dependencies I added freeglutD.lib.
In the code I just include a freeglut header. When I want to run the program I get an error:
>LINK : fatal error LNK1104: cannot open file 'freeglut.lib'.
The freeglutD.lib is the only file in sdk/freeglut/lib. There is no freeglut.dll and freeglut.lib in sdk.
Earlier I was using freeglut 2.8.0 MSVC Package from link which is linked dynamically (contain freeglut.dll) and everything works fine.
What is wrong ?

My guess is that you forgot these lines from the documentation on using the SDK:
You will also need to add some #defines to your command line. These are:
FREEGLUT_STATIC
_LIB
FREEGLUT_LIB_PRAGMAS=0
You need that FREEGLUT_STATIC to let GLUT know that it's linking statically. Otherwise it looks for a DLL.

I had an older project from VS12 and got the same LNK1104 error when trying to build it after upgrade in VS15. All I had to do to fix this was run Package Manager Console (Tools - NuGet Package Manager) and type in:
Install-Package freeglut
Note, that I have reference to glew.h and freeglut.h in one of my header files like this:
#include "..\packages\nupengl.core.0.1.0.1\build\native\include\GL\glew.h"
#include "..\packages\nupengl.core.0.1.0.1\build\native\include\GL\freeglut.h"

Related

VCPKG, not a found command right after installing it?

I am trying to use #include<graphics.h> in visual studio code to display graphics in C. When I used graphics.h as a header the following error occurred,
#include errors detected. Please update your includePath. Squiggles are disabled for this translation unit (C:\Users\natha\Desktop\My OS\src\impl\kernel\main.c).C/C++(1696)
cannot open source file "graphics.h"
So as the quick fix suggests it shows me how to install a library for this header with VCPKG (https://vcpkg.io/en/getting-started.html). When I follow the steps by cloning the repository and running the bootstrap, I go to install the graphics package but the cmd says that 'vcpkg' is not a found command. I'm not sure why it says this or how to fix it.
Add the vcpkg.exe binary path to the PATH environment variable
or run vcpkg from the directory where you installed

sphinxclient.h header is not found on debian

I'm trying to use the C client library of http://sphinxsearch.com in my project. It compiles fine on ubuntu using libsphinxclient-dev package
However when I try to compile it on debian sid, it complains that the header sphinxclient.h is missing, and I can't find any package providing this header.
Is there any "clean" way to solve this problem ?
Seems libsphinxclient is not included in Debian upstream and there isn't a separate package.
You can grab the deb packages from Sphinx website,libsphinxclient is installed in /usr/share/sphinxsearch/api/libsphinxclient (you might need to copy the header to include folder or add this folder to path).

CMake: Header files cannot be opened

I am working to build a Code Composer Studio project using cmake, which is new to me. It builds successfully under Linux but I am struggling to get it to work under Windows. The cmake command executes without issue, but make fails during the very first C object at the very first #include with the error code
fatal error: could not open source file "stdbool.h" (no directories in search list)
I'm using the libraries included in CCS's compiler (c6000_7.4.15), and that whole folder is included in the CSS project. I include it in cmake as well. In my .cmake file:
set (CCS_ROOT ${CCS_ROOT_V6_WIN} CACHE PATH "code composer install directory")
set(CGT_COMPILER_ROOT ${CCS_ROOT}/tools/compiler/c6000_7.4.15 CACHE INTERNAL "DSP Compiler Root")`
And in the CMakeLists.txt file:
set (COMPILER_INCLUDE ${CGT_COMPILER_ROOT}/include)
INCLUDE_DIRECTORIES ("${COMPILER_INCLUDE}")
Why can the header files not be opened when they're linked in the project and CMake can find them just fine?
EDIT: The directory structure had been changed underneath me, so I took the opportunity to add all of the external files directly into the project to make it completely platform-independent. That way, since the project is managed by our Git repository, users won't have to install the CSL or any other programs to build the project. This also means that paths to libraries and header files will never change between revisions and environments.
Unfortunately, this has not solved my problem. The project continues to build in Linux while failing to ind the very first included header file. I also notice that, under Windows, it cannot find my own header files unless I provide a relative path, e.g. #include "../Common.h" I can get make to find stdbool.h if I provide an absolute path to the compiler directory, but that exposes a web of additional broken links between files.
As a side note, the project builds successfully within Code Composer Studio, so I am assuming that this isn't an issue with my specific Windows environment nor with the code within the project itself.
This seems to be an issue with gcc.exe. I set an environment variable CC to the path of a different compiler (in my case a TI compiler) within my build script and that fixed the problem.

How do I link libraries in Xcode 4?

I'm a complete beginner to Apple's Xcode, but I have followed the Xcode documentation and the advice of a few related questions without success.
I installed GMP to /usr/local/bin, wrote a short program using the library, and compiled with gcc main.c -lgmp. It compiled with no warnings or errors, and the executable worked flawlessly.
I started a new Xcode project (Command Line Tool; Type: C), copied the code to the newly created main.c, and opened the project build settings. From there I set Linking > Other Linker Flags to -lgmp and Search Paths > Library Search Paths to /usr/local/bin. However, the build fails with the preprocessor error "Gmp.h: No such file or directory".
I have tried almost every header imaginable:
#include "gmp.h"
#include <gmp.h>
#include "gmp"
#include "libgmp.a" . . .
This has been my main obstacle over the last three months which has prevented me from learning C. Any help leading me to an eventual solution would be greatly appreciated.
There's a few things you have to set up in your Xcode project. For example, I have gmp installed in /opt/gmp/5.0.2 and I will use that as an example. The actual library is installed into /opt/gmp/5.0.2/lib and the header files into /opt/gmp/5.0.2/include. When installing the library setting the --PREFIX flag to /opt/gmp/5.0.2 would handle this automatically. If you don't set this flag the prefix is usually set to /usr/local by default.
The Other Linker Flags looks right, it should be the name of the library.
Set the Header Search Path to the include directory, in my case /opt/gmp/5.0.2/include.
Set the Library Search Path to the lib directory, in my case /opt/gmp/5.0.2/lib.
Since the header search path has been set, you should now be able to include the header file like this:
#include <gmp.h>
Of course, replace /opt/gmp/5.0.2 with the PREFIX path you used when you installed gmp.
Lastly, you typically don't install libraries to /usr/local/bin, you would install to /usr/localand let any binaries be installed into bin while libraries like these would be installed into lib. Of course any path scheme would work, I usually recommend /opt/<project-name>/<version-number> since it allows me to keep better track of what I have installed and have multiple versions of the same libraries and tools without having to deal with collisions.
I have updated my system from snow leopard to mountain lion and had to install gmp.
First of all I have installed Xcode CommandLineTools set.
Secondly, installed Homebrew. Then with it I have done steps in this topic: https://apple.stackexchange.com/questions/38222/how-do-i-install-gcc-via-homebrew
In my last step, made changes to an xcode project as colleague Marcus Karlsson told.
It's finally working! Very big Thank You :)

How to get opencv include work in kubuntu? (Includes solution to how to include and link in netbeans 6.7.1)

I have installed OpenCV C libraries from package management into my Kubuntu 9.10. I wrote a small image modification program that uses those libraries, but I can't compile it, because every time I try to compile I get the error message that the functions from OpenCV library cannot be found.
Those header files are in folder /usr/include/opencv/ but still the compiler says that functions cannot be found.
I have tried to include them by basic
#include <highgui.h>
#include <cv.h>
commands in netbeans (and I have set netbeans to search header files from that specific directory) and also tried to include them with full path.
#include </usr/include/opencv/highgui.h>
#include </usr/include/opencv/cv.h>
Also I tried to compile my source file in console (with full path includes), but again I got the same error message that the functions from those libraries cannot be found.
Edit:
The error message that I get is
undefined reference to 'function_name'
I get that error for every function that I try to use from that opencv library.
Any idea how to fix that problem?
Edit II:
in case someone else is using netbeans 6.7.1 and has the same problem, here's the solution copy pasted from another website:
Here I presume that you have succesfully installed the opencv library either manually or via package management.
Open Netbeans then do the following:
Select Tools -> Options -> C/C++ -> Code Assistance -> add Include Directories
(For me, /usr/local/include/opencv)
Create new project, then:
Right click on Project Name -> Properties ->Build -> C/C++ Compiler -> Include Directories
Include Directories : /usr/local/include/opencv
Right click on Project Name -> Properties -> Build -> linker ->
Include Directories : /usr/local/include/opencv
Additional Options : -I/usr/local/include/opencv -L/usr/local/lib -lcxcore -lcv -lhighgui -lcvaux -lml
Then writing program and compile!!
"undefined reference to" is a linker error. You forgot to link your application against the OpenCV libraries. Make sure you link against cv and highgui (-lcv -lhighgui) or use the pkg-config call that Tobu provided. I'd also second the request for more detailed error messages.
OpenCV uses pkg-config, the standard way to locate libraries and headers on unix. You can run (untested):
make CFLAGS="$(pkg-config --cflags --libs opencv)" your-program

Resources