Skip to content

Fontzs/CS205

Repository files navigation

CS205 is a c/cpp course of SUSTech. The instructor is Shiqi Yu

Resources

Windows11 WSL指定路径安装 ubuntu

GDB Documentation

Note

Building shared libraries

  • Let's build a shared library
  • Remember to use arguments "-shared" and "-fPIC" when building it
  • Now we should see "libfunction.so" in the directory
g++ -shared -fPIC -o libfunction.so function.cpp

Using shared library

  • Now we can use "printHello" function with the ".h" header file and the ".so" shared library

  • Let's compile main again:

    g++ -o main -L. main.cpp -lfunction
  • Use "-L." to tell it to find libraries in current directory

  • USe "-lfunction" to tell it to use "libfunction.so".

  • After the "main" has been compiled, try to run it

./main
  • Using export command to set environment variable "LD_LIBRARY_PATH"
  • AND then run "main" again
export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH
echo $LD_LIBRARY_PATH

About

SUSTech C/C++ course

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors