1

I'm familiar with C, but haven't written any medium or large application in it. I have a requirement to built an application that can be run as a standalone console application as well as Fast-CGI and Apache module.

I'm thinking of implementing the core functionality as a Static Library and then write a wrapper for console, Fast-CGI and Apache module.

As I'm not a C expert, I was wondering what are my other options. Having the core functionality in a standalone binary and calling it using system calls from the wrappers would work also, however I can't fully write down the pros and cons of each.

Also the software is supposed to run on GNU/Linux machines, so I'm very open to follow the community conventions.

Mahdi
  • 1,983
  • 2
  • 15
  • 25

2 Answers2

1

Why dont you write the core functionality as a dynamic link library in a sdk fashion with clear defined Interface for all the other components so you dont have to link the lib to each need ex. Console application etc.

mitro
  • 111
  • 2
  • Would this make the installation harder for the user, perhaps by requiring extra steps to set it properly? Besides that, my main argument could be that it will make the initialisation slightly slower -- specially in the Fast-CGI configuration, and perhaps there aren't any need for having it as a dynamic library rather static library, or are there? Would it save my development time if I go for a dynamic library? – Mahdi Dec 02 '15 at 13:58
1

The reason for using a dll is to ship changes to that dll only, the interface wrappers will be unchanged. YMMV if you ship all 3 components simultaneously, so building a static lib and shipping everything each time the code gets an update isn't a bad idea in that case.

You could also consider embedding a webserver (like mongoose or civetweb) in your application so the user can just start it up and get full web functionality without needing apache or fastcgi at all.

gbjbaanb
  • 48,354
  • 6
  • 102
  • 172