Linker warnings with GLFW - linker

I am trying to use GLFW for a school project, and have followed these steps:
1) Download the win32 zip from glfw.org
2) Add /include to my solution's includes
3) Add /lib-msvc100/debug to my solution's libraries
4) Link against glfw.lib and opengl32.lib
5) #include GL/glfw.h
While the project compiles and runs just fine, I can't get around a slew of the following errors:
Warning LNK4099: PDB 'vc100.pdb' was not found with
'glfw.lib(enable.obj)' or at '-projectdir-\Debug\vc100.pdb'; linking object as if no
debug info
One other post here (LNK4099 in GLFW console project with debug configuration) talks about accidently linking both static and dll, but I have not done so. I cannot submit a project with compilation errors :-/
Any idea what's going on here, and how to fix it? Much obliged

You are using the debug version of the GLFW binary, but the vc100.pdb debug information database wasn't included in the zip file. It's a relatively harmless warning and simply means you won't be able to debug normally inside GLFW functions. However, you wouldn't be able to anyway, as the zip file doesn't have the GLFW sources either.

This solved the problem for me:
Open the GLFW project in the solution and go to C++ general options. For all platforms, change the debug build's "debug information format" to "Program Database". Recompile.

Related

(C) How to link dlls within CLion

I've been programming C for a while with Visual Studio, but now switched to CLion. My programming and target system is Windows10.
Within Visual Studio, I was able to include the required DLLs like "vcruntime140d.dll" and "ucrtbased.dll" inside my exe.
I did this by going into the project settings and set configuration settings - C/C++ - code generation - runtime library to "Multithreaded-Debug (/MTd)".
Doing this I was able to run the resulting exe without having errors like "vcruntime140d.dll is missing" or "ucrtbased.dll is missing".
But how can I achieve this within CLion?
I've been searching for a while now, and I found a lot of tutorials on how to include .lib files but not for DLLs (I don't have the code for).
With Clion, you actually are working with CMake. So the question is to be like how to link dlls within CMake.
There are many ways to do. e.g.
link_libraries
target_link_libraries
If the library could not be found by default, use find_library to search for it.
If these functions seems too strange to you, check this tutorial from the CLion team.
Update
As in the comment you asked, your problem is how to load a dll without lib. To address this, you could dynamicly load the dll, or make a lib from the dll.
For Windows multicopies problem, add following into your CMakeLists.txt
foreach (flag_var
CMAKE_C_LINK_FLAGS
CMAKE_C_LINK_FLAGS_DEBUG
CMAKE_C_LINK_FLAGS_RELEASE
CMAKE_CXX_LINK_FLAGS
CMAKE_CXX_LINK_FLAGS_DEBUG
CMAKE_CXX_LINK_FLAGS_RELEASE
CMAKE_EXE_LINKER_FLAGS
CMAKE_EXE_LINKER_FLAGS_DEBUG
CMAKE_EXE_LINKER_FLAGS_RELEASE
CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL
CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL
CMAKE_CXX_FLAGS_RELWITHDEBINFO)
string(REPLACE "/MD" "-MT" ${flag_var} "${${flag_var}}")
endforeach ()

gtk.h missing in Visual Studio for Linux Development

I'm currently trying to write an app for Raspberry Pi 3B under Rasbpian with aid of Linux Development plugin in Visual Studio 2017 Community. I managed to successfully deploy 'Blink' example, nobly attached by Microsoft folks, according to tutorial, and that went well. I even made some transmission over SPI thanks to wiringPi library. Then I would like to add some GUI to my app, so that one could, for example, make some transmission on click of a button on screen.
IntelliSense hinted me, that, in fact, there is gtk-3.0 library present in toolset. It seems that libraries are being copied from target device on every connection or so and I installed gtk on my Raspberry. So I added a simple line to this Blink example:
#include <gtk-3.0/gtk/gtk.h>
On compilation attempt, of course there was nearly 4k errors. Well, enough said, with a little hint from this old tutorial and a bit of trial and error, I managed to add this set of links under Debugging/Project properties/Configuration properties/VC++ directories/Header files directories:
Everything goes in promising direction, as errors number diminished from 4k to just one:
gtk-3.0\gtk\gtk.h: No such file or directory
No matter that this file is ACTUALLY in this location:
Regardless of combination of links in configuration above and using statement composition, compiler (?) can't find this damn file.
Please Halp
EDIT
I just confirmed, that it is indeed problem with target configuration. This is bad or good, depending on point of view. Good, because there is probably all good with VS setup. Bad, because I don't know a thing about compiling things under Linux.
On target (Raspberry Pi 3B) all ingredients for compilation are copied by Linux Development plugin. So in Terminal I executed line:
g++ main.cpp -o Blink2onRPi
and got
main.cpp:4:21: fatal error: gtk/gtk.h: no such file or directory
Now, I altered include line in main.cpp on target RPi, to this:
#include <gtk-3.0/gtk/gtk.h>
And now its missing <gdk/gdk.h>! When this change is made on host windows device - same result, but in VS.
As I dealt with similar problem in VS, upon setting links for IntelliSense (now apparently they're for this purpose), now probably similar dependencies have to be set somewhere on Raspbian. But where?
EDIT2
Upon execution of:
g++ main.cpp -o Blink2onRPi `pkg-config --cflags --libs gtk+-3.0`
on target RPi there is no more GTK-related errors, just wiringPi (also present in project) undefined references. It raises two possible questions:
1) How can I setup wiringPi on RPi so that the project could be manually compiled on target and
2) How/where add above line to Visual Studio, so it execute remotely with all GTK dependencies added properly on target
Researching stock present wiringPi library (as this is Blink led example for cross-compile Linux Development) I've found, that in Project Properties/Linker/Input/Library Dependencies there is mysterious entry:
wiringPi
Just that, nothing more. After removing this entry, on compilation pops out same errors as before on target (which apparently lacks proper wiringPi setup) - undefined references (not mensioned any missing headers). Can this be relevant for the case? If so, how could I add there such entry which would deal with missing GTK dependencies?
TL;DR
Use screenshot below to know where to add pkg-config calls in VS configuration so that it forwards it to the compiler and linker on the target.
Thanks to #zaguoba for providing these.
ORIGINAL ANSWER:
The list of directories to include is provided by pkg-config. For example pkg-config --cflags-only-I gtk+-3.0 will give you the list of include directories required. Those are the ones you need to add to the directories where VC++ wil look at include files. If you add the relative path you use in the #include, to one of those paths, you are able to find the file.
Example:
If you add to the directories C:\Program Files\foo\bar\gtk+-3.0
and have in your C file:
#include <gtk/gtk.h>
then the compiler will look for C:\Program Files\foo\bar\gtk+-3.0\gtk\gtk.h.
EDIT:
This all means the 'file not found' errors are because you're really building on the target and the target has no idea what C:\Program Files\... means. Those should be paths on the target filesystem, where the compiler is called. And this is exactly what pkg-config provides.
The copy of those files on the Windows machine filesystems is merely for Intellisense use, not for compiler use.
EDIT 2:
So that's that Visual Studio 2017 Community Linux Development plugin is what need to be undestood. It's not for cross compilation from Windows to Linux, istead it merely synchronizes code to the Windows host (for Intellisense use), but builds on the target. This means that all the paths and commands are Linux paths and commands, run on the target.
Here's the OP working configuration:
With that setup, you should
#include <gtk\gtk.h>
instead of
#include <gtk-3.0\gtk\gtk.h>
Alternatively remove all those VC++ directories/Header files directories, and just keep one of them that ends with include/ instead of listing up all the sub directiores.

VS Visual GDB intellisense not finding library, but compiles properly

In particular, #include "sqlite3.h" gives an error [Clang Intellisense] Error: 'sqlite3.h' file not found in Visual Studio.
Everything works fine when compiling/running, but the intellisense errors are annoying.
I've installed sqlite3-dev and ran updates/upgrades.
I see sqlite3.h in the usr/include directory which is included in the list of intellisense directories under project properties.
sqlite3 is included in the Library names (Makefile settings -> Config settings)
Is my path going to the wrong library or am I just missing something simple? I don't see the sqlite.c file in there and looking the the .h file, I don't see the functions I am using (from an example) like SQLITE_OK or sqlite3_free.
Again, everything works, it's just the intellisense that doesn't work. At least from what I can tell so far.
Oh, and the code is running on raspbian if that matters.
Yes, I experience the same the first time I open the solution. But I managed to get rid of it by opening one of the included header files and a clean Rebuild.
my VS version is 2015

How to use CUDA 6.0 with XCODE 5

My question may completely be a noob. Sorry, for that but I have been trying to compile my first Cuda code in Xcode and I'm lost where and how I could set up the IDE to invoke NVCC.
I installed the latest CUDA toolkit CUDA 6.0 and have even installed GCC 4.8 using brew. I have XCODE 5.5
When I run my code from XCODE all the directives like global are marked as unidentified.
I don't where and to change the settings to invoke NVCC. I will be really thankful, if anyone could help me with this.
Further, when I created the XCODE project, I created it as a C project. So, I placed the CUDA code in this C file, which is what is giving me the above mentioned errors. I tried to replace this .C file with a .cu file (just change the extension), which too failed badly - XCODE didn't even know what to do with the .cu files
COuld anyone please help me?
Thanks in Advance
I have given it a try. Although I have not completely succeeded I thought I'd post my progress here in hopes of helping others. The steps I took were inspired by this page.
Create a new Xcode project
Under Build Settings add a new user defined setting CC with the value /usr/local/cuda/bin/nvcc.
Add /usr/local/cuda/include to Header Search Paths under Build Settings.
Set Enable Modules (C and Objective-C) to No.
Add /usr/local/cuda/lib/libcuda.dylib to Link Binary With Libraries under Build Phases.
For any C files you create set their extension to .cu in the File Inspector, after you have done that you have to set the type of that file to C source to get syntax highlighting, by going to Editor->Syntax Coloring->C.
Problems with this setup:
- Xcode can't run the executable, at least nog if it is compiled for debugging. However you can make it copy the executable to some reasonable location and run it in the terminal.
- Whenever you try 'Build for running' sometimes Xcode magically destroys the whole project.

Why Isn't My C Code Being Compiled To An EXE

I'm just starting out writing trying to write a simple program in C and I am using Visual Studios to do so. I heard that it does compile C as well as C++. And I know that it does because it says it compiles. The only problem is that when I go to the output directory, there isn't a .exe file in the directory! It has the following:
BuildLog.html
mt.dep
test1.obj
vc90.idb
vc90.pdb
But that is all! No EXE. I've looked through all the options and made sure that it is set to compile to an exe and i checked the output file. That is $(OutDir)\$(ProjectName).exe. But alas, no exe appears. Any ideas?
Also when i try to hit f5 and run with debut i get an error that says
This application has failed to start
because MSVCR90.DLL was not found.
Re-installing the application may fix
this problem
By default when you're creating a new C++ project within a new solution, you're getting folder structure like this:
C:\Projects\YourSolution
C:\Projects\YourSolution\YourCppProject
YourSolution contains YourSolution.sln and YourCppProject contains YourCppProject.vcproj.
When you build the solution, all intermediate files from YourCppProject are getting stored under YourCppProject\Debug or YourCppProject\Release, but resulting YourCppProject.exe goes under YourSolution\Debug or YourSolution\Release.
Your $(OutDir) is configured by General -> Output Directory. Check project configuration for YourCppProject and see that it uses $(SolutionDir) for the output.
is it a C/C++ console application?
did you use the project wizard to create it?
do you have a function like
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
printf("Hello, world!\n");
return 0;
}
in a .c module, typically main.c?
what happens when you hit F5 to run-with-debug?
what does your build log look like?
The simplest thing to do is just start over, making sure you choose the right kind of project.
To compile plain old C code with Visual Studio, choose Visual C++ > General > Empty Project from the New Project menu. This creates 3 empty folders: Header Files, Resource Files, and Source Files. Right click on Source Files, choose Add > New Item. Then add a main.cpp, rename it to main.c, and start coding.
http://msdn.microsoft.com/en-us/library/ms235299.aspx
Note:
It is not supported to redistribute
C/C++ applications that are built
without a manifest. Visual C++
libraries cannot be used by C/C++
applications without a manifest
binding the application to these
libraries. For more information, see
Choosing a Deployment Method.
If the DLL is not reachable and
Windows cannot load this DLL for your
application, you may get the following
error message:
This application has failed to start
because MSVCR90.dll was not found.
Re-installing the application may fix
this problem.
To resolve these errors, you must make
sure that your application is built
correctly and Visual C++ libraries are
correctly deployed on the target
system. To identify the root cause of
these run-time errors, follow the
steps outlined in Troubleshooting
C/C++ Isolated Applications and
Side-by-side Assemblies.
HTH
Sounds like you only hit compile, that will give you you're .obj file, but you still need to click build.

Resources