tags:

views:

186

answers:

1

I'm trying to compile a simple c++ program to run inside ESXi 3.5 console window. It seems I'm linking with wrong libraries... Is there a setup described somewhere - which version of G++ and libraries do I have to be using in order to do so?

+1  A: 

Here's how I resolved the issue. I did following to compile:

  1. Compiled using gcc under ubuntu
  2. Ran ldd on executable
  3. Copied all libraries that showed up as dependencies to subfolder ESXi-3.5-lib. In my case they were:

    ld-linux.so.2
    libc.so.6
    libgcc_s.so.1
    libm.so.6
    libstdc++.so.5
    
  4. Added following switches to gcc:

    • -nodefaultlibs (to not attempt to link with default libs)
    • -lc (prevented link error in some crt library)
    • -fno-stack-protector (prevented another error, some other function was missing)

Following was my final build command:

g++ file1.cpp file2.cpp file3.cpp -o output-biinary-file-name \
    ESXi-3.5-lib/ld-linux.so.2 ESXi-3.5-lib/libc.so.6 ESXi-3.5-lib/libgcc_s.so.1\
    ESXi-3.5-lib/libm.so.6 ESXi-3.5-lib/libstdc++.so.5  \
    -nodefaultlibs -lc -m32 -fno-stack-protector
galets