Can I link a plain file into my executable?
You could do this:
objcopy --input binary \
--output elf32-i386 \
--binary-architecture i386 my_file.xml myfile.o
This produces an object file that you can link into your executable.
This file will contain these symbols that you'll have to declare in your C code to
be able to use them
00000550 D _binary_my_file_xml_end
00000550 A _binary_my_file_xml_size
00000000 D _binary_my_file_xml_start
Qt :How to make hyperlink to exe file
You can use this code :
QLabel *lbl = new QLabel;
lbl->setText("<a href='file:///c:/fg740p.exe'>Open</a>");
lbl->setOpenExternalLinks(true);
lbl->show();
substitute c:/fg740p.exe with the path to your .exe file.
And as you may know Open is what displayed to user.
C/C++ with GCC: Statically add resource files to executable/library
With imagemagick:
convert file.png data.h
Gives something like:
/*
data.h (PNM).
*/
static unsigned char
MagickImage[] =
{
0x50, 0x36, 0x0A, 0x23, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20,
0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4D, 0x50, 0x0A, 0x32, 0x37,
0x37, 0x20, 0x31, 0x36, 0x32, 0x0A, 0x32, 0x35, 0x35, 0x0A, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
....
For compatibility with other code you can then use either fmemopen
to get a "regular" FILE *
object, or alternatively std::stringstream
to make an iostream
. std::stringstream
is not great for this though and you can of course just use a pointer anywhere you can use an iterator.
If you're using this with automake don't forget to set BUILT_SOURCES appropriately.
The nice thing about doing it this way is:
- You get text out, so it can be in version control and patches sensibly
- It is portable and well defined on every platform
How do I derive an executable name from a source file in Meson build?
It should work if you define your variable simply as array, e.g.:
my_test_files = ['test_foo.c','test_bar.c','test_baz.c']
the loop stays the same, except some typo fixed with:
foreach t_file : my_test_files
t_name = t_file.split('.')[0]
test(t_name, executable(t_name, t_file, ...))
endforeach
instead of building array of file objects. This is because executable() accepts input files in many forms: as file objects (which you tried to do) and as strings either source files (that should be compiled) or object files (to be linked) - detected by file name extension.
For more flexibility and better control, one can use array of arrays (which is, of course, extendable and may contain anything that is needed to generate tests):
foo_files = files('test_foo.c')
bar_files = files('test_bar.c')
baz_files = files('test_baz.c')
test_files = [
['foo', foo_files, foo_deps],
['bar', bar_files, []],
['baz', baz_files, baz_deps]]
foreach t : test_files
test(t[0], executable(t[0], t[1], dependencies=t[2], ...))
endforeach
qmake: compile single cpp file into an executable
To make an additional executable you can use use system()
in .pro like so:
system(g++ otherapp.cpp)
Which will be built every time you call qmake
. However if you want to build the additional app automatically when its source is changed, use QMAKE_EXTRA_TARGETS instead.
How can I convert a JAR file to an EXE file?
See this link: Java to Exe. It also explains what valid reasons are to do this, and when you should not.
You can't really encrypt binaries as the machine has to understand them. That said, an optimized executable is very difficult to decompile, while plain class files are ease.
If you have an exe there are installers enough.
Related Topics
Constructor Invocation Mechanism
How to Avoid Static Member Function When Using Gsl with C++
Errors When Linking to Protobuf 3 on Ms Visual C
Compute Objects Moving with Arrows and Mouse
What Exactly Is Streambuf? How to Use It
How to See the Template Instantiated Code by C++ Compiler
Video Stabilization with Opencv
Use Std::Fill to Populate Vector with Increasing Numbers
Why Doesn't Emplace_Back() Use Uniform Initialization
Constexpr VS. Static Const: Which One to Prefer
C++ Ifstream Failbit and Badbit
What Happens When I Mix Signed and Unsigned Types
Makefile: How to Correctly Include Header File and Its Directory
Boost_Static_Assert Without Boost
C++: How to Require That One Template Type Is Derived from the Other