How to add libraries in Visual Studio in a Linux cross-compilation project? - linux

I'm new to Linux (rpi 3) and trying to create a window application on it from my Windows PC with Visual Studio. Creating a console-application is no problem, since it doesn't require any libraries.
And the way I understood it is that there is no real standard Linux library for GUIs like Win32 on Windows, so you need to add external libraries.
I went for QT and downloaded already compiled files from qtrpi.com for the rpi3.
I added the lib path for the linker and the include path for the compiler on the projects properties page, but all I get is
1>/home/pi/projects/WindowProject/main.cpp:2:27: fatal error: QtGui\qwindow.h: No such file or directory
1>#include <QtGui\qwindow.h>
1> ^
What am I missing? This works without a problem on normal projects, only that it wouldn't run, since it is for Linux.

Related

Generate CUDA program dlls under Linux

I know that mingw creates a dll file under windows which can be used to create an exe file. We can execute this exe file in windows. I am working on a cuda project under Linux, but have to deliver the product for Windows as well. Is it possible to generate a dll file using some sort of method under windows?
On windows, MinGW is not supported for CUDA development. The only compiler which is officially supported by CUDA is cl.exe which ships with Microsoft Visual Studio.
More details can be found in System Requirements section of CUDA Getting Started Guide.
Here is an MSDN tutorial which describes how to create a C++ DLL using Visual Studio.
For compiling CUDA kernels, you would have to add CUDA Build Rules in the Build Customizations section of the Visual Studio DLL project.

Various issues installing igraph in Visual Studio 2010 and Cygwin/MinGW ("sys/time.h not found")

I couldn't get igraph to work with Visual Studio 2010 (supposedly many known issues), and so decided to try installing it in Cygwin. ./configure went fine. But make gave this error:
f2c/dtime_.c:16:23: fatal error: sys/times.h: No such file or directory
Makefile:2190: recipe for target `libf2c_la-dtime_.lo' failed
make[3]: *** [libf2c_la-dtime_.lo] Error 1
I tried installing it in MinGW and get the same error when I make. Should I be providing "sys/time.h" or a path to it? Where is sys/time.h? Using Windows 7.
Edit
The problems in Cygwin and MinGW was due to the wrong version of gcc being used by my clean installation of Cygwin (and a characteristic of MinGW). Solution here: Installing/compiling in Cygwin/MinGW - How to set the include "path"? (symbolic link?)
The problem in Visual Studio 2010 was due to building in "Debug" instead of "Release". One of igraph's creator, Gábor Csárdi, graciously provided an excellent step-by-step guide below that identified and resolved it.
Igraph actually does work with Visual C++ 2010 Express, we test this before releases, and I have just tried it. You need to do the following steps.
Download the source package specifically created for Visual Studio.
Uncompress the file into My Documents\Visual Studio 2010\Projects.
Open the igraph.sln solution file in igraph-0.6-msvc\igraph-0.6-msvc directory from Visual Studio.
Visual Studio offers to convert the solution file to the current format, do that. Just click on Next, Next and Finish.
On the toolbar, change 'Debug' to 'Release' to make release builds.
Choose Debug -> Build solution and wait until the library is built.
To test it you can open the solution file in the igraphtest directory, convert it as well, choose 'Release' builds, and then build it and run it from the command line. It is a simple C++ program that uses igraph to create a graph and write it into the file out.txt.
You don't have to set up include and library directories at all, everything is set up properly in the solution file, both for igraph and igraphtest.
is there an sys/times.h file?
I have a vague memory that I had to make that symlink on a system once.

LNK1112 module machine type 'X86' conflicts with target machine type 'x64' (VC++ 2005)

I am trying to build a blank, 64-bit C++ application in Visual Studio 2005 Professional using these steps:
Create a new Win32 Console Application project
Go to Configuration Manager, create new Solution Platform of type x64, copy settings from Win32
Save & build
However, I get this error:
LINK : fatal error LNK1104: cannot open file 'kernel32.lib'
So, I tried updating the library directories to point to kernel32.lib:
Go to Project Properties, Linker, General, Additional Library Directories and set
"C:\Program Files\Microsoft Visual Studio 8\VC\lib\amd64"
Save & build
This gives me the error:
LINK : fatal error LNK1104: cannot open file 'user32.lib'
So, I tried updating the library directories to point to user32.lib:
Go to Project Properties, Linker, General, Additional Library Directories and add
"C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib\x64"
Save & build
But now I am getting the error:
.\x64\debug\stdafx.obj : fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64'
Any ideas what I am doing wrong?
It sounds like the problem is with the object file stdafx.obj rather than the system libraries. The warning is saying that stdafx.obj is 32-bit so it can't link into a 64-bit target. Things to try:
Delete the build directories x64 and win32
Rebuild the project
Check the build settings for stdafx.cpp to ensure it's building as 64-bit
Must've been a broken installation of Visual Studio. A new installation of Windows and VS2005 fixed the problem.
Its been long since the question was asked, but for the benefit of others who happen to read this, the change required is in the linker flag setting. Change /machine:I386 to /machine:x64

fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'AMD64'

I am using VS 2003 .Net on 32 bit XP OS. I have also installed "Microsoft Platform SDK" on my machine. Can I build vc++ application (binaries) targeted for 64 bit OS?
I am using following project options :
Name="VCLinkerTool"
AdditionalOptions="/machine:AMD64 bufferoverflowU.lib"
OutputFile="\bin\Release\MM64.dll"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
AdditionalLibraryDirectories=""C:\Program Files\Microsoft Platform SDK\Lib\AMD64""
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="\bin\Release\MM64.pdb"
GenerateMapFile="TRUE"
MapFileName="\bin\Release\MM64.map"
MapExports="TRUE"
MapLines="TRUE"
OptimizeReferences="2"
EnableCOMDATFolding="2"
ImportLibrary=".\Release/MM64.lib"
TargetMachine="0"/>
I am getting following error:
fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'AMD64'
Do I need to build project on 64 bit OS or I need to change project settings to resolve this error.
Please help me to resolve this issue.
I had the same problem today, here's how I solved it (in Visual Studio 2008):
Went to Project Properties -> Linker -> Command Line -> Additional Options and removed the /MACHINE:I386 from the linker additional options.
Hope it helps
Having the same problem in VS2008. My solution was to change the active solution platform located in Build -> Configuration Manager and creating a new solution platform using the x64 and copuing the settings from Win32. This allowed me to use the pre-build 32bit libraries in my 64 bit OS.
For 64-bit Windows users:
I had the same problem today, here's how I solved it (in Visual Studio 2008): I went to:
Project Properties -> Linker -> Command Line -> Additional Options
and added the /MACHINE:I364 from the linker additional options.
This worked fine for me.
I faced above error when I tried to build my custom library for ARM64 in Visual Studio 2017. And my target machine was already ARM64 as expected.
Apparently, problem was in ARM64 compiler which was not installed(though I could run build in ARM64). I installed it by running Visual Studio Installer Individual Components -> Visual C++ compiler and libraries for ARM64
Next I got error MSB8022: Compiling Desktop applications for the ARM platform is not supported.
It was resolved by adding
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration">
...
<PlatformToolset>v141</PlatformToolset>
<WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support>
</PropertyGroup>
into my project file.
After all of above I could succefully build my project in ARM64.
Hope it will be useful.
This error comes up because something in you build is being compiled in the wrong architecture (say as a x86 binary when everything else is x64). The linker panics and doesn't know what to do with it, so it breaks your build.
I can speak for your problem because the error message you quoted is incomplete. Usually it goes something like this:
SOME_KIND_OF_OBJECT.obj: fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'AMD64'
You look at the name of the obj file and you'll find the root of your problem there. Whatever obj is listed will have some kind source code analog with the same name. Have a look at it and see how it's being compiled. Usually all that stuff is automated in VS but sometimes there are special build steps that were added in by the developer. Inspect the custom, pre- and post- build events to see if a x86 tool is being used to assemble it. The property sheet in VS2010+ will be specific to the obj and the platform so you can inspect the library directories being used to verify that they are not 32 bit.

A converted vc++ 2003 project asks for msvcpd71d.dll when compiled on vc++2008

After running the conversion wizard for a VC++ 2003 project - which ends with no errors - I get VC++ 2008 to sucessfully compile the project. Then, when launching the exe, a message pops up saying that the program cannot start because MSVCP71D.dll is missing. Any ideas on why a project compiled on vc++ 2008 would ask for MSVCP71D.dll ?
TIA
Update: I am trying to compile the ARToolkit using VC2008.
http://sourceforge.net/projects/artoolkit/files/artoolkit/2.72.1/ARToolKit-2.72.1-bin-win32.zip/download
What binary files came with the project? You seem to be linking against a static library or DLL that was built with VS7.1 -- hopefully you can rebuild that file in VC9 there.
Also, for what it's worth, note that the D at the end of "MSVCP71D.dll" indicates that it's looking for a debug build of that DLL.
The ARToolkit has several libraries in the lib folder, some of which with that same "d" suffix indicating a debug build -- those libraries were most likely built in VS2003 given your results. I'm not sure if you can rebuild in VS2008 from the lib/SRC directory, but that might be a start.
Looks like you need to build it as "release" so that the application does not look for that debug library at run-time.

Resources