What is your little C++ program? What libraries is it dependent on and are they statically linked? Chances are the standard C++ library (and others) is being statically linked.
#include <iostream>
int main(int argc, char* argv[])
{
std::cout << "Hello, world!" << std::endl;
return 0;
}
#include <iostream>
int main(int argc, char* argv[])
{
std::cout << "Hello, world!" << std::endl;
return 0;
}
To copy to clipboard, switch view to plain text mode
Static versus dynamic linking:
$ g++ -o test1 -static main.cpp
$ g++ -o test2 main.cpp
$ ls -l test?
-rwxr-xr-x 1 chrisw users 1293108 Jul 7 13:14 test1
-rwxr-xr-x 1 chrisw users 7330 Jul 7 13:14 test2
$ g++ -o test1 -static main.cpp
$ g++ -o test2 main.cpp
$ ls -l test?
-rwxr-xr-x 1 chrisw users 1293108 Jul 7 13:14 test1
-rwxr-xr-x 1 chrisw users 7330 Jul 7 13:14 test2
To copy to clipboard, switch view to plain text mode
The static version is much larger but needs no external libraries. The dynamic version is tiny but has external requirements. They both do the same thing. Take a close look at the compile command that Qt Creator is building for you.
Bookmarks