MinGW portability - c++

I'm completely new to C++, but I have created a minor program, looking to port the program to other computers, but when I "install" the program I get this error...-static-libgcc -static-libstdc++ missing, is there a file I should be including in the program itself, or is this a library I have to install on each computer? The computers that I expect to run the program will be windows xp. Source code of the file is as follows:
#include <stdlib.h>
#include <windows.h>
#include <direct.h>
#include <string.h>
#include <string>
#include <iostream>
using namespace std;
int main(int argc, const char *argv[])
{
_chdir("C:\\Program Files\\NCHSoftware\\Talk\\");
string number = "start talk.exe -dial " + std::string(argv[1]+4);
system(number.c_str());
exit;
return 0;
}

They are shared lib's that would need to be on the host computer.
To learn how to compile a static version;
See here: http://gcc.gnu.org/onlinedocs/gcc/Link-Options.html
Read the "-static-libgcc" & "-static-libstdc++" sections.

Related

Fatal error when compiling #include <sys/uio.h> on project [windows]

trying to compile a file for class, using the mingw compiler on windows 10. Compiling with g++ gives me an error stating
\projectFile.o
mingw32-g++.exe -o D:\GitHub\GitRepo\projectFile.exe D:\GitHub\GitRepo\projectFile.o
D:\GitRepo\projectFile.cpp:16:20: fatal error: sys/uio.h: No such file or directory
compilation terminated.
From what ive read this header file
#include <sys/uio.h>
is a unix header and is generally included with most unix build environments. I am working on Windows 10 build and have been unsuccessful in trying to get this to work. Is there a work around for windows using different headers? Is there a while to install this file somehow?
The project is a generalized XML parser that as a student my job is to extract functions from the main file so that they can be reused (OOP design space)
#include <iostream>
#include <iterator>
#include <string>
#include <cstring>
#include <sys/types.h>
#include <sys/io.h>
#include <unistd.h>
#include <errno.h>
#include <vector>
#include <algorithm>
#include <ctype.h>
#include "XMLParser.hpp"
Built on Windows 10 (lastest build) with Mingw-64 (lastest version)
This will not compile for me
This fixed my problem creating this uio.h file in sys directory of mingw64
#ifndef SYS_UIO_H
#define SYS_UIO_H
#include <inttypes.h>
#include <unistd.h>
struct iovec
{
void *iov_base; /* Base address of a memory region for input or output */
size_t iov_len; /* The size of the memory pointed to by iov_base */
};
ssize_t readv(int fildes, const struct iovec *iov, int iovcnt);
ssize_t writev(int fildes, const struct iovec *iov, int iovcnt);
#endif /* SYS_UIO_H */

Using DLLs wrapping Windows PackageManager in MinGW

In an attempt to incorporate a windows platform feature into an otherwise crossplatform application, I've made a one-function VC++ DLL in visual studio that uses Windows.Management.Deployment.PackageManager to get some details on all installed windows store apps.
The function works fine as a standalone application, and I can successfully build the DLL with MSVC that links properly with my MinGW main application (I can happily return primitive data from the dll, etc) - but any attempt to execute a function from the dll containing code relating to PackageManager crashes my application in runtime with the unhelpful code -529697949.
Here's some minimal code blocks that replicate:
main.cpp in the main application:
#include <QCoreApplication>
#include "mylib/WindowsAppsLib.h"
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
auto hi = (Helpers::sayHi());
qDebug() << (hi);
return a.exec();
}
dll header:
#pragma once
#define WINDOWSAPPSLIB_API __declspec(dllexport)
namespace Helpers
{
extern "C" WINDOWSAPPSLIB_API const char* sayHi();
}
dll source:
#include "stdafx.h"
#include <sddl.h>
#include <collection.h>
#include "WindowsAppsLib.h"
#include <windows.h>
#using <Windows.winmd>
using namespace Platform;
using namespace Windows::Foundation;
using namespace Windows::Foundation::Collections;
using namespace std;
const char* Helpers::sayHi()
{
auto packageManager = ref new Windows::Management::Deployment::PackageManager();
auto packages = packageManager->FindPackages();
return "Hi!";
}
Without the two lines relating to packagemanger, the program runs fine and prints "Hi!". When included, the program crashes with code -529697949 as soon as sayHi() is called. The two lines in themselves have their dependencies available and don't cause exceptions.
Any clues on how I might proceed to investigate this? Nothing I've been able to get out of this system is getting me closer to identifying the problem. Is this the sensible way to access Windows.Management.Deployment.PackageManager from within a plain C++ MinGW application to begin with?

VCOS does not name a type

I'm, trying to output video from raspicam to framebuffer 0, and I'm having an issue with BCM_HOST, where I get a ton of errors from the included vcos.h.
All the errors are of the same 2 types:
'VCHPRE_' does not name a type,
'vcos_boot_t' has not been declared,
In files: connection.h vc_ispmanx.h, message.h etc.
etc.
I'll link to a full pastebin of errors below
I don't even know where to begin solving these, I moved /opt/vc from raspbian to my sysroot folder using VisualGDB's synchronize sysroot feature, and all the include files are there.
Is this a problem with the files themselves? It can't be,
Thanks for any help,
-D
Pastebin link: https://mypastebin.com/xQdN7mZZInHx
Example:
#include <stdio.h>
#include <syslog.h>
#include <fcntl.h>
#include <linux/fb.h>
#include <sys/mman.h>
#include "bcm_host.h"
using namespace std;
int main(int argc, char **argv) {
{
DISPMANX_DISPLAY_HANDLE_T display;
DISPMANX_MODEINFO_T display_info;
DISPMANX_RESOURCE_HANDLE_T screen_resource;
VC_IMAGE_TRANSFORM_T transform;
uint32_t image_prt;
VC_RECT_T rect1;
int ret;
int fbfd = 0;
char *fbp = 0;
struct fb_var_screeninfo vinfo;
struct fb_fix_screeninfo finfo;
return 0;
}
Ok, it seems that using VisualGDB sysroot synchronize tool causes some files to be copied with 0 length. I checked vcos.h and it was empty, but on my linux system it had data. Fixed by copying all the files manually.

LLVM compilation errors on VS 2012

I have built the LLVM using CMake using VS 2012 in keeping with documentation. I am trying to build a toy compiler with flex, bison and LLVM. The final stage of my compiler my main class looks like this:
#include <iostream>
#include "codegen.h"
#include "node.h"
#include "llvm/Target/Targetmachine.h"
using namespace std;
extern int yyparse();
extern NBlock* programBlock;
void createCoreFunctions(CodeGenContext& context);
int main(int argc, char **argv)
{
yyparse();
std::cout << programBlock << endl;
InitializeNativeTarget();
CodeGenContext context;
createCoreFunctions(context);
context.generateCode(*programBlock);
context.runCode();
return 0;
}
As stated in my previous post LLVM 3.4 linker errors in VS 2012. To workaround the solution I manually added the x86 files I was missing (taking clue from the errors). I ended up adding the following to the main:
#include "llvm-3.4/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h"
#include "llvm-3.4/lib/Target/X86/InstPrinter/X86ATTInstPrinter.h"
#include "llvm-3.4/lib/Target/X86/InstPrinter/X86IntelInstPrinter.h"
#include "X86MCAsmInfo.h"
#include "llvm/ADT/Triple.h"
#include "llvm/MC/MCCodeGenInfo.h"
#include "llvm/MC/MCInstrAnalysis.h"
#include "llvm/MC/MCInstrInfo.h"
#include "llvm/MC/MCRegisterInfo.h"
#include "llvm/MC/MCStreamer.h"
#include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/MC/MachineLocation.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/TargetRegistry.h"
#include "X86GenRegisterInfo.inc"
#include "X86GenInstrInfo.inc"
#include "X86GenSubtargetInfo.inc"
But I noticed that the following are missing from my system:
"X86MCAsmInfo.h"
"X86GenRegisterInfo.inc"
"X86GenInstrInfo.inc"
"X86GenSubtargetInfo.inc"
I looked through the online documentation but I am a beginner on the topic, most of it did not make too much sense to me. I would appreciate if someone could guide me or point me to the right tutorial which gives me a better understanding of what I am doing wrong here.

Simple netbeans C++ project doesn't compile

I installed Netbeans and as C++ compiler I installed cygwin. I made a simple project to test out my installation, this is the code:
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
cout << "test";
return 0;
}
This is the error message that it gives: http://pastebin.com/jRRh7MPi
I hope you guys can help me out.
You need to either explicitly link to C++ standard library, or compile using g++ instead of gcc.