Dev-c++ compilation and linking problems - c++

I've inherited a dll file and its source code and I need to rebuild it. The dll file exports functions that are needed in another application. It was originally made using an older version of dev-c++ (probably a few years back). When I try to build it, the compilation process goes fine and the object files are created, but I get an error during the linking process. Here's an excerpt from the output of the compile log.
g++.exe: error: unrecognized command line option '--no-export-all'
g++.exe: error: unrecognized command line option '--add-stdcall-alias'
I am looking for a solution to this problem, solution meaning being able to rebuild the dll. I do not have contact with the creator of the source code. Any suggestions, ideas or answers would be much appreciated. I am using dev-c++ 5.11 and using the TDM-GCC 4.9.2 32-bit compiler.

Related

Unable to open file DFM using cmake on c++ builder 10.3

I am getting the following linker error in my project.
Error: Unable to open file 'FOO.DFM'
I am compiling with the old borland compiler (not clang) and building using cmake rather than the IDE. I have added the directory of the dfm file to target_include_directories. Compilation is successful but having this issue with multiple dfm files at the linking stage.
In the .cbproj file of the ide this is used like the following way:
</CppCompile>
<FormResources Include="foo.dfm"/>
UPDATE:
I'm wondering is this because the delphi compiling isn't occurring through cmake (dcc32). Is this supported or do you need to have a custom add_custom_command in your cmake to handle this. C++ Builder docs doesn't seem to mention any delphi compilation.
In the IDE build output one of the initial tasks is the delphi compilation, you can see c:\program files (x86)\embarcadero\studio\20.0\bin\dcc32.exe -B but this is not happening in cmake output

wxWidgets with MinGW, "wx/wx.h: No such file or directory"

I am new to C++ and wxWidgets. During the last couple of days, I have followed a tutorial with Visual Studio into how to build wxWidgets desktop applications (https://www.youtube.com/watch?v=FOIbK4bJKS8&t=800s).
Now, because I am not familiar with Visual Studio, I wanted to move to edit the code with Atom and compile with MinGW from Windows command prompt.
The app has the following files:
cMake.h
AnalogRead.h
cMake.cpp
AnalogRead.cpp
In Visual Studio, you need to include two directories and one library in the project, which are the following:
Paths:
/wxWidgets/include
/wxWidgets/include/msvc
Libraries:
/wxWidgets/lib/vc_lib
Relative to the path where the the C++ code is.
So I have tried to create the compile line, without success:
c++ -I/wxWidgets/include -I/wxWidgets/include/msvc -L/wxWidgets/lib/vc_lib cMake.cpp AnalogRead.cpp -o test
But I get the following error:
In file included from AnalogRead.cpp:1:0:
AnalogRead.h:3:19: fatal error: wx/wx.h: No such file or directory
#include <wx/wx.h>
^
compilation terminated.
The thing is, I am including that path in the compilation. wx/wx.h is inside the path /wxWidgets/include/.
Is there a way to fix this? Thanks in advance.
You can't compile the library with one compiler and then compile the application using it with another, this is just not going to work. You should decide which compiler you want to use (or maybe try using both of them, but not both at the same time!) and follow the official build instructions in the file docs/msw/install.md.
/wxWidgets/include is not a relative path. This is an absolute path in the current disk. Do you have C:\wxWidgets\include? Try -IwxWidgets/include or -I./wxWidgets/include, without the leading /. This path should work if you have the wxWidgets directory in your app sources.
If you want to use MinGW, you need to build the library with MinGW compiler and then use EXACTLY THE SAME command to buid your software.
Or use an IDE (CodeBlocks, CodeLite).
HTH.

Qt with MinGW: g++: error: CreateProcess: No such file or directory

I have a project originally build with Qt 4.8.6 for Embedded linux + ARM. This project is a user interface which has already been coded to be compiled as a Windows Desktop app and years ago I successfully did so. Now I have to recompile it once again for Windows, but I keep getting this error
g++: error: CreateProcess: No such file or directory
when getting to the point of compiling main.cpp.
Solutions found on the web didn't help. Steps done:
I was originally trying to compile it with Qt 5.7. Thinking it could be library incompatibility, I installed Qt 4.8.6 with correspondent MinGW version. [EDIT] I tested the installation with a Hello World program achieving 100% success
Following this link, I added the paths of both the new Qt and MinGW to PATH, no success. Notice that I'm able to perfectly compile and run other projects with Qt 5.7 and it is not linked in PATH.
Following this link, I went to conclude I had several libraries linked to the project which were not compiled yet. I managed to successfully compile all of them and double checked the inclusion paths in my .pro file. This was clearly a problem to be solved, but it didn't help with the issue in question.
I checked for any new libraries that could be incompatible with Windows; found one and put its header inclusion inside a define. No results.
So now I'm without ideas. Unfortunately I don't remember getting this error when I compiled the app for Windows years ago, so I don't even have a clue on what is happening. Here is the message I get in Compile Output:
Any help will be appreciated.
I managed to find the solution to the problem.
The .pro file had a define DEFINES += COMPILE_DATE=\\\"$$DATE\\\" which was calling the define DATE =$$system($${PWD}/../../get_compile_date.bat). The .bat file this define was pointed out is somehow incompatible with Windows. Its contents is date | tr -d " ". Once the call to this file was commented, the problem stop occuring.

Windows build with -mwindows flag no executable

I had problems building a program I'm working on in C++ because MinGW files and Windows SDK file were conflicting and I found the solution by adding the -mwindows flag for the linker to the build options. This works: now I can build the project without errors.
But now the compiler doesn't output any executable file (.exe).
My question is: why? And what exactly the -mwindows does?
Edit: The output of the build phase is reported in a text file in this Dropbox folder (I couldn't copy it here because it's more than 2800 lines): https://www.dropbox.com/sh/1ud85a3fktb62v6/AAB3L8Vp5VcKPJqCPyOXtzdca?dl=0
I already tried to create a new 'Hello World' project and build it: the executable file is created and I can run it, so I think the cause of my problem is that flag and not a particular setting on my IDE (CLion).

g++ ignoring header files

So I am trying to create a exec with g++. My command is as follows:
g++ -o project21 main.cpp tools.hpp file.hpp FileInfo.cpp file.cp tools.cpp
I get an error
ld: warning: ignoring file tools.hpp, file was built for unsupported file format which is not the architecture being linked (x86_64)
ld: warning: ignoring file file.hpp, file was built for unsupported file format which is not the architecture being linked (x86_64)
The behavior here is that odd is that I can compile it in XCode and using the exec just fine it is just in the shell that I am having the problem.
You don't need to compile the hpp files. Include them in your .cpp files.
Even if you include the hpp on your project, Xcode won't compile them, unless you explicitly ask it to (my mac is at work, but if I recall click the project (root of the tree at the left), click a target and check the tab build phases, there is a list with the files to compile).
About the segmentation fault, if it were missing source files (i.e, you added code in the .hpp files that really should be on a .cpp file), then you would get a link error, and not a segmentation fault. There are other reasons to the segmentation fault, run on GDB and debug it (compile with -g to be able to debug). Here are some possibilities:
If you are building for a different platform, the problem may be some platform specific code.
Compiler incompatibility: assuming you were using Xcode with LLVM, you may have some code that works with LLVM but behave different with gcc. Very unlikely (by my experience with those compilers, I can say they are very compatible), but still possible.
Try deleting any *.gch files that may have been created by the Xcode build before trying your g++ command.
However, in general I'd try to get things working without pre-compiling the header files first, then add the pre-compiled header optimization if it's necessary (i.e., don't pass the .hpp files to the compiler explicitly until you've got everything else working and only if you really need to).