C++ DLL g++ gygwin conio.h - c++

I have been reading those pages:
http://www.mingw.org/wiki/sampleDLL
What I understand is that I need a ...dll.cpp and a ...dll.h file. Out of those two I build a .DLL
Then I link myProgram.ccp which uses functions of the DLL to the latter.
Now here comes my problem, these are the files that are avaliable:
FirstSteps.cpp
PI_GCS2_DLL.dll
PI_GCS2_DLL.lib
FirstSteps.sln
FirstSteps.vcproj
PI_GCS2_DLL.h
FirstSteps.suo, FirstSteps.vcproj some Visual studio stuff that I don't have available, hence we are left with
FirstSteps.cpp
PI_GCS2_DLL.dll
PI_GCS2_DLL.lib
PI_GCS2_DLL.h
Now I thought as the .dll is already there I just have to compile and link the FirstSteps.cpp to the PI_GCS2_DLL.dll
But already
g++ -c FirstSteps.cpp
causes
$ conio.h>FirstSteps.cpp:9:19: fatal error: conio.h: No such file or directory
-bash: conio.h: command not found
I have never programmed under windows before.... Can anyone help me? How can I compile that thing?
Here is the link to the files
https://www.dropbox.com/sh/7c3srahdyhdxmy7/AACe48ZFroiXNao5VXtgANZKa
I am sitting in front of this shit already the whole day... I am really thankful for help.
Greetings,
newandlost

Related

MinGW: Internal error when building a C++ program

I had been running C++ programs with G++17 quite comfortably, when one day for no apparent reason, this error shows up:
internal error in mingw32_gt_pch_use_address, at
config/i386/host-mingw32.c:190: MapViewOfFileEx: Attempt to access
invalid address.
Below is the complete error output:
[Finished in 4.5s with exit code 1]
[cmd: ['g++.exe', '-std=c++17', '-D DIV_DEBUG', 'D:\\Codes\\code.cpp', '-o', 'code.exe', '&&', 'code.exe<inputf.in>outputf.in']]
[dir: D:\Codes]
[path: C:\Python38\Scripts\;C:\Python38\;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\MinGW\bin;C:\ProgramData\pbox;C:\Program Files\nodejs\;C:\ProgramData\chocolatey\bin;C:\Program Files\Git\cmd;C:\Users\asus\AppData\Local\Microsoft\WindowsApps;C:\Users\asus\AppData\Local\Programs\Microsoft VS Code\bin;C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin;C:\tools;C:\Users\asus\AppData\Roaming\npm;C:\Users\asus\AppData\Local\atom\bin]
I've been searching for a solution for three days now and haven't found it yet. It looks like a bug in MinGW but I do not know how to fix this. My last option is to delete everything related to MinGW and reinstall it. Any better ideas are appreciated.
The code which I'm trying to compile.
#include <bits/stdc++.h>
int main() {
std::cout << "Hello, World!\n";
return 0;
}
It appears that removing the "bits/stdc++.h" header file removes this error. I would still like to know how I can fix this as I use this library on a daily basis for all my programs.
Edit: I tried building on Windows Powershell but the same error comes up.
PS D:\Codes> g++.exe -std=c++17 -D DIV_DEBUG code.cpp -o code.exe
internal error in mingw32_gt_pch_use_address, at config/i386/host-mingw32.c:190: MapViewOfFileEx: Attempt to access invalid address.
Update: Tried reinstalling MinGW. It didn't work.
Okay, so the issue went as miraculously as it had appeared. I precompiled the header files after reinstalling MinGW and for some reason, it fixed the issue. I'm not sure if this action triggered the fix.
If someone can throw some light on this strange behaviour, I would mark that answer as accepted.

Mosquitto.h not such file or directory

I am working on a c++ project using mosquitto library on github. I am trying to compile the C++ on a windows computer on the command line; however I keep getting error
Fatal error: mosquitto.h: no such file or directory
include "mosquitto.h"
I have installed the mosquitto library in the windows system, underneath:
C:\Program Files\mosquitto\devel\mosquitto.h
Is there something else that I have to do as well in order to compile the cpp from the command line. How do I tell g++ the whereabout of the mosquitto.h file. So I can compile on the command line
Thank for your help I am new to C++.
I managed to solve this question, I had o copy the mosquitto.h into
C:\cygwin64\usr\include
Then when I type g++ nameOfFile it compiled

c++ undefined reference to PathFileExistsW (_imp__PathFileExistsW#4)

I'm trying to build headless blackcoin from source on Windows 8 with mingw 6.3
and I got the following error: .../src/leveldb/libleveldb.a(env_win.o):env_win.cc:(.text+0xaff): undefined reference to '_imp__PathFileExistsW#4'
This function is mentioned here https://msdn.microsoft.com/en-us/library/windows/desktop/bb773584(v=vs.85).aspx
I would appreciate if someone can help me.
P.S. I linked the appropriate library.
Finally I was able to build it. Probably it is obvious for thoose guys who down voted the question. I simply answer since it might save time to somebody.
I relied on the Makefile which is a part of the project source code. Required library (shlwapi) present in the file so I was confused when it failed to build. Everything went well when I placed the library at the end of the linked files.
It was something like this
g++ ... -o -lshlwapi... /src/leveldb/libleveldb.a /src/leveldb/libmemenv.a
And became this
g++ ... -o /src/leveldb/libleveldb.a /src/leveldb/libmemenv.a -lshlwapi

Linker errors with codelite, unittest++ and g++ on linux

I'm new to unit testing in c++, and writing c++ on Linux (Mint). I'm using CodeLite as my IDE. I have found several answers on stackoverflow about linker errors, but after hours of trying various solutions I have not succeeded in implementing a solution correctly.
I installed unittest++ through apt-get. The unittest++ header files were installed in /usr/include, so I added this to the Compiler linker options in Codelite (Right click project name->Settings, Compiler):
Codelite screenshot
I then have a very simple program, which consists entirely of one main.cpp file:
#include <unittest++/UnitTest++.h>
//See if unit tests are working
TEST(MyMath) {
CHECK(false);
}
int main()
{
UnitTest::RunAllTests();
return 0;
}
Running the project at this point generates a stream of linker errors other users have experienced, for example:
main.cpp:4: undefined reference to UnitTest::CurrentTest::Details()
At this point, my understanding is that I now need to tell the g++ compiler about the object files and link them to the unittest++ files. And this is where I'm stuck. The only .o file I see is in Debug/main.cpp.o and running the command
g++ main.cpp -o main.cpp.o -Lunittest++
as well as variations with the I and o flags, but all of them return the same linker errors I get when I try to compile. I've also tried to copy every g++ line in the forums and only get various errors.
I've tried to find a solution in the g++ man pages, read about the flags I've been using and did not infer a solution. I then quickly got buried in quantity of pages in the man entry. The documentation for CodeLite and unittest++ seems woefully out of date, so I posted here on stackoverflow as a last resort.
I'm fairly certain I'm just making a rookie mistake. If someone has feedback, I'd be grateful.
In your explanation, you try to link manually with g++ -c main.cpp -o main.cpp.o -Lunittest++ , but the -L option gives the path to additional directories to search for libraries. You probably want -lunittest++ to link with the unittest++ library. That library should provide the symbols you see in the "undefined reference" errors.
As a side note, "/usr/include" should be in the default search path and there's no need to add it explicitly.

ERROR LNK1104 - .`obj` file without any file name

I am trying to compile a project where i am getting this error. I am very new to c++ and dont know much about VC++. And the most irritating part is that the error does not mention a name to the .obj file!!! Here is the whole error [copied from Error List] :
Error 1 error LNK1104: cannot open file '.\Debug\.obj' E:\7zsrc\CPP\7zip\Bundles\Format7zF\LINK 7z
To be more specific, I am compiling the Format7zF bundle included with 7z source version 9.22ß. I have already tried most of the solutions out there but most times either the the problem is different or the solution does not work.
Any help would be great!
Thanks
Update
I just noticed [from the .log file] that at the end of the linker Debug\\.obj was added! Hope this explains the problem more!
Update 2
I am attaching a copy of the project. You can examine the project by opening the solution from [ExtractionPathOfTheArchive]\CPP\7zip\Bundles\Format7zF\ Directory. Hope someone can help.
Link to Project Source("d.zip")
I have just converted the source files from VC++6 to VC++12 and changed the Output File Path in linker to inherit from..., nothing else.
It's Too late, but for records. :)
I had same problem, when I converted the 'QUAKE' project from VC6 to VS2010.
I solved it by changing setting of '.s' files (asm code file).
Check [Properties/Configuaration Properties/Custom Build Setup/General/Outputs]
and there are "$(InputName).obj" macro, then try to change it as "%(Filename).obj".