I did a QT project in windows 10. But it needs to run in Linux CentOS. They asked me to send the bin file to them. But I don't know how to convert cpp to bin. I googled and in a website it was written that only renaming to bin would be enough. I tried to rename '.cpp' extension to '.bin'. But it doesn't work. Is there any tools to do this?
I think you misunderstood the instructions. What is expected from you is to provide a compiled version of your program that can run on CentOS.
A compiled program is often referred to as a binary.
For QT, it seems possible to compile on Windows for CentOS: http://doc.qt.io/qt-5/configure-options.html#cross-compilation-options
Related
I'm trying to compile a windows program (a rather simple one, it merely shows a window and plays a sine wave) on Linux. To make sure it's not an X-Y problem, I'm trying to do so for my own convenience, as I'm too used to my Linux hotkeys, workflows etc.
Anyway, what I did is I installed g++-mingw-w64, grabbed a w32api.tar.xz from mingw sourceforge (https://sourceforge.net/projects/mingw/files/MinGW/Base/w32api/w32api-5.0.2/), unpacked it in my project directory, grabbed libgcc_s_sjlj-1.dll as described in this post (https://www.linux.org/threads/how-to-use-windows-h-c.28353/#post-88213), and am trying to compile the project with
i686-w64-mingw32-g++ -I w32api/include/ -L w32api/lib/ source/win32_handmade_linux.cpp
What I'm getting is:
In file included from w32api/include/winsock2.h:62,
from w32api/include/_winsock.h:50,
from w32api/include/windows.h:85,
from source/win32_handmade_linux.cpp:30:
w32api/include/winsock.h:54:10: fatal error: sys/bsdtypes.h: No such file or directory
54 | #include <sys/bsdtypes.h>
| ^~~~~~~~~~~~~~~~
compilation terminated.
Googling it doesn't really help; I can't find that file anywhere on my system, including my Windows installation living on another hard drive. I'm confused. I have to say, I'm not experienced at all with cross-platform compiling, so maybe I'm doing something stupid in the first place and am just not aware of it.
Maybe I took wrong steps there? All windows-specific headers I need are
#include <windows.h>
#include <xinput.h>
#include <dsound.h>
But maybe it's too hard to achieve anyway, and I should abandon that idea and just compile and run the program under a VM, and develop it on Linux?
So, as #BrechtSanders told, I don't need a separate w32api or anything like that, if I already had mingw installed.
Essentially what I did is I've located the headers that came with mingw (on my system, that's /usr/share/mingw-w64/include/), located the libgdi32.a (/usr/i686-w64-mingw32/lib/libgdi32.a), and changed the compile command to
i686-w64-mingw32-g++ -I /usr/share/mingw-w64/include/ win32_handmade_linux.cpp /usr/i686-w64-mingw32/lib/libgdi32.a
while deleting bogus DLLs and w32api subdirectory. All works! Moreover, after a little tinkering (I had to put Z:\\usr\\lib\\gcc\\i686-w64-mingw32\\9.3-win32\\ to path in system.reg in my wine config), the resulting executable runs perfectly under wine!
I am trying to program in C++ using Eclipse. However, this requires Eclipse to work on different computers with a MinGW compiler installation everytime. I know that it will work if I install it on a computer and add the location to the PATH variable, but I want to know how to put the compiler onto my USB as well as the Eclipse program and make it work the same way.
It should be installed in such a way that Eclipse can find the compiler on my USB (without the PATH stuff and C drive installation) and compile my program successfully without giving a "Binary not found" error because it could not build my source code.
I've solved this problem with Eclipse Java and am completely able to write and compile Java code. However, I don't know how to do it for a C\C++ Eclipse. Can someone help me with this problem?
Thanks in advance!
You do not need to alter system-wide path variable to help Eclipse finding your compiler. Simply create a batch file, which modifies and exports PATH. For example, put the following in the same directory as eclipse executable:
set PATH=%PATH%;path-to-mingw-bin
your-eclipse-executable
Save it as, for example, StartEclipse.bat, and execute it. (of course your-eclipse-executable should be given relative to the working directory of the batch script, and path-to-mingw-bin must be an absolute path)
You can install your MinGW anywhere, not necessarily in C:\, so installing it shouldn't be a problem.
I am trying to do some DSP operations in C++ using Octave...I have been trying to integrate Octave with QtCreator 5.1 (MinGW compiler) with no success...I have done the following steps...
Downloaded Octave3.4.3_gcc4.5.2-install.exe and intsalled in C drive. I have added the address of the bin folder of octave to the environmental variable PATH
Set the INCLUDEPATH and LIBS according to the location of the header files and the libraries of the Octave directory.
This is the sample program I am trying to run .
The code builds successfully. However while running it hangs up. Debugging yeilds the following message.
I tried to create an executable using the command prompt of octave using the command mkoctfile --link-stand-alone octavetest.cpp -o octavetest. The executable created also hangs up with an error message.
If anyone can point out where exactly I am going wrong in the integrating process it would be realy helpful. Is there any other simple way to set up the environment to call Octave APIs from C++? I have almost checked on the internet forums including stack overflow with no luck...
Your gcc/libstdc++ version will likely be incompatible with the one octave got compiled with.
This compiler is as close as i got to the one used to build the current octave-binaries.
If you extract both archives and add their bin directories to your path variable, you should be able to build octave programs. Your linked sample builds for me.
You can also add the compiler in QtCreator. (Tools⇒Options⇒Build&Run)
I have done exactly the same thing on Windows. In my experience, you need to build Octave with exactly the same compiler that you're building your executable with. That's all there's to it. This really means you have to build Octave from sources. I have wasted a lot of time avoiding to build Octave, and in the end could never be sure that it'll be stable or not. Octave will build with VS 2012 with very minor tweaks.
Building Octave is really the only practical way to go, I think. The amount of time you spend setting up an Octave build will insignificant in the long run.
I have a quick question on a topic that I'm quite a noob about. I have a program I made that sends a command to another .exe in a folder I called "tools". I send it in this format:
system("tools\\program.exe -r -w file.dat file_new.dat");
Everything works great, however, when I build my program into a .exe it will require the other executable to be in a second folder, obviously. Is there any way to include the external .exe into my project so the final product is just one .exe?
I am using Visual Studio 2008 (lol) and run windows 7 64bit.
Thanks :)
Typically, the management of external dependencies would be handled by the installer. NSIS is my favoured solution for the Windows platform.
The alternative: Convert the binary to a base64 encoding and embed it as a header file in your project. When the application is run, convert the base64 representation of the exe to a binary sequence and then output that sequence of bytes to a file in a temporary directory (like C:\windows\temp or %AppData%\Local\Temp). Then run the exe. Once you're done with it, remove the exe.
You can add the file to resources. And before the command is executed, you can check, if the second executable exists. If it doesn't exist, you have to extract the data from resource and store to the file...
This thread was dealing with reading html from resource. It is very similar with binary file.
I've downloaded the midiIO library and in the readme it says:
edit the file Makefile.library and set the OSTYPE and OSSUBTYPE to match your hardware/os setup.
type "make library" to compile the library. It will be created as lib/libmidiio.a in unix.
edit the file Makefile.examples and set the OSTYPE and OSSUBTYPE to match your hardware/os setup.
Also, if you are using ALSA, then uncomment out the POSTFLAG to use the alsa library (-lasound).
type "make examples" to compile the example programs in the examples directory. The example programs will be place in the bin directory.
1 + 3 are fine but 2 + 4 are over my head. I've worked in a unix environment before and have used gcc with flags but I need to get this done in Windows. I typically use Visual Studio but don't know how to achieve this with that.. I've downloaded Dev-C++ if that's any use but I don't know what to do with the makefiles?
Ignore the makefiles and set up a fresh project in Visual C++. Make your target a static library (which will be a .lib file in Win32, not a .a file as in unix as you probably know). It is unlikely that the project will build out of the box, so you might have to deal with some compilation errors relating to unix-specific symbols. I took a quick look at the source code, and it looks fairly well-written, so I don't think you should have many problems building it directly in Windows.
Alternately, you could build the source using the real make tool in cygwin, but this means that you would need to distribute the cygwin library with your final product. This may or may not be more trouble than it's worth, especially if you are already using VC++ for the rest of your project's code.