My code:
#include <fcgi_stdio.h>
int main() {
int count = 0;
while(FCGI_Accept() >= 0) {
printf("Content-type: text/html\r\n");
printf("\r\n");
printf("Hello world!<br>\r\n");
printf("Request number %d.", count++);
}
}
In a fresh instance of multipass, I installed gcc
, g++
and libfcfgi-dev
as
sudo apt-get install gcc
sudo apt-get install g++
sudo apt-get install libfgci-dev
But attempting to compile the code using g++ -std=c++17 -lfgci++ -lfcgi main.cpp -o main
gives the error
in function main: undefined reference to `FCGX_Init` ...
But this doesn't happen when I try to compile in gcc:latest
docker container. The dockerfile is
FROM gcc:latest
RUN apt-get update -yqq;
apt-get install -yqq libfcgi-dev
COPY ./main.cpp /home/main.cpp
CMD g++ -std=c++17 /home/main.cpp -lfcgi++ -lfcgi -o /home/main
What am i missing in the multipass instance?
Like it was mentioned in the comments, it was indeed the case. I didn't know that and I totally missed that it was in the right order in the
dockerfile
. It was a really simple thing indeed but thanks to S.M for his quick response in pointing out the silly mistake. Hope this also helps out some other fellow newbie stumbling upon this issue in the future.