title: How do I compile a c++ program into a 32-bit executable instead of 64-bit
body: <p>So I am trying to compile a c++ program and have the executable be 32-bit instead of 64-bit. The system (using a program to simulate a system) I want to run it on is 32-bit and seeing as compiling the program yields 64-bit ELF files I cannot run them. I have added the -m32 flag to the makefile and when compiling i get the following errors:</p>
  <p>/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.so when searching for -lstdc++
  /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a when searching for -lstdc++
  /usr/bin/ld: cannot find -lstdc++</p>
  <p>when using sudo apt install -lstdc++ it simply says it cannot find the library. Anybody perhaps able to give me some direction? I am running all of this using remote wsl in visual studio code on a windows 10 machine. Ultimately I just want the compiled executables from this program to be 32-bit ELFs instead of 64-bit.</p>
  <p>This is the make file The program im trying to compile is a benchmark suite located here <a href="https://github.com/alifahmed/hopscotch" rel="nofollow noreferrer">https://github.com/alifahmed/hopscotch</a>. This is the makefile otherwise located in /cpu/2_bandwidth:</p>
  <pre><code>TARGET =    bandwidth
  
  .PHONY: all clean $(TARGET)
  
  # directories
  INC_DIR = ../include
  KERN_DIR = ../kernels
  CMN_DIR = ../common
  OBJ_DIR = obj
  
  
  # compiler flags ADDED -m32 FLAG
  CXX = g++
  CXXFLAGS = -m32 -O3 -fopenmp -march=native -I$(INC_DIR) -std=c++14 $(USER_DEFS)
  
  
  # header files
  HEADERS = $(wildcard $(INC_DIR)/*.h)
  
  
  # src files
  SRC = $(wildcard *.cpp) $(wildcard $(KERN_DIR)/*.cpp) $(wildcard $(CMN_DIR)/*.cpp)
  
  # object files
  OBJ = $(SRC:.cpp=.o)
  
  all: $(TARGET)
      
  clean:
      @rm -rf $(OBJ)
      @rm -rf $(TARGET)
      @echo &quot;Cleaned...&quot;
      
  %.o: %.cpp $(HEADERS)
      $(CXX) $(CXXFLAGS) -c -o $@ $&lt;
  
  $(TARGET): $(OBJ)
      $(CXX) $(CXXFLAGS) $^ -o $@```
  </code></pre>