The order of the gcc arguments is important.
Try
gcc -Wall -g hwserver.c -lzmq -o hwserver
You need to first warn, optimize or debug flags (for example, -Wall for all warnings, -g for debugging information), and then optional preprocessor flags (for example, -D or -I , but you donβt have them), then the source files and finally, the -lzmq libraries (the order is relevant: from high-level libraries to low-level ones) and the output version is -o hwserver (which may be in another place).
Read the gcc documentation, in particular the chapter calling GCC .
Remember -Wall : you really want to get all warnings, and you should improve your code until warnings are given. You may even want -Wextra to receive additional warnings.
Don't forget the -g debug info flag: you will need to use the gdb debugger to debug your program.
Later use -O or -O2 to optimize the binary program (then the compiler will produce more efficient, but less debugged machine code). Only take care of this when your program is debugged.
As soon as you want to develop real-size C programs (that is, your project from several source files and some header files [s]), you will need a builder infrastructure such as GNU make (a very general builder, you can try omake ).
See also this answer to the corresponding question.
source share