Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
763 views
in Technique[技术] by (71.8m points)

c++ - How do I compile a .cpp source file into a .dll?

How do I compile a .cpp source file into a .dll?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

There are two steps you need to follow in order to compile a dll:

  • Compile your source files to object files
  • Link your object files to a dynamic link library (DLL)

Here is one example using gcc:

  1. gcc -c source.cpp //compile sources; will output "source.o"

  2. gcc -shared -o mydll.dll source.o //add -shared to create a dll, will output "mydll.dll"


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...