Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerfile Project Help Needed #1296

Closed
DragonOsman opened this issue Oct 13, 2018 · 6 comments
Closed

Dockerfile Project Help Needed #1296

DragonOsman opened this issue Oct 13, 2018 · 6 comments
Labels
state: needs more info the author of the issue needs to provide more details

Comments

@DragonOsman
Copy link

DragonOsman commented Oct 13, 2018

I need some help on a Dockerfile project based on the app I made. I got an error saying that there's no such file or directory as nlohmann/json.hpp. I got similar errors for Jinja2Cpp, but I'll ask that on their GitHub rather than here (though if someone here can help me with that, then that's even better for me).

The command I'm using in the Dockerfile to compile my executable is:

RUN g++ -std=c++17 -Wall -pedantic -I /usr/local/jinja2cpp/install/include -I /usr/local/boost_1_68_0/ -I /usr/local/json/single_include/ -L /usr/local/jinja2cpp/build/ -llibjinja2cpp.* -L /usr/local/boost_1_68_0/stage/lib/ -llibboost_system.* currency_converter.cpp -o currency_converter

The error from g++ during the Dockerfile build process is:

currency_converter.cpp:29:10: fatal error: nlohmann/json.hpp: No such file or directory
 #include <nlohmann/json.hpp>
          ^~~~~~~~~~~~~~~~~~~
compilation terminated.

This is my code (I posted it on GitHub as well): https://github.com/DragonOsman/currency_converter/blob/master/currency_converter.cpp .

Any help is appreciated. Thanks.

@nlohmann
Copy link
Owner

As you passed -I /usr/local/json/single_include, can you make sure the file /usr/local/json/single_include/nlohmann/json.hpp exists?

@Manu343726
Copy link

Manu343726 commented Oct 15, 2018

As noted in jinja2cpp/Jinja2Cpp#70, looking at your Dockerfile and its build script would help to diagnose the problem.

@nlohmann nlohmann added the state: needs more info the author of the issue needs to provide more details label Oct 16, 2018
@DragonOsman
Copy link
Author

Okay, I took out the flag to bring in nlohmann/json from the regular include directory and kept just the single_include one, but I still have that error. Relevant part of the Dockerfile build output is:

Cloning into 'json'...
Checking out files: 100% (1804/1804), done.
Removing intermediate container c6b8c75af70e
 ---> a122c5924902
Step 8/12 : RUN g++ -std=c++14 -Wall -pedantic -I app/jinja2cpp/install/include -I app/json/single_include -I /usr/local/include/ -I app/jinja2cpp/thirdparty/nonstd/value-ptr-lite/include currency_converter.cpp -L app/jinja2cpp/install/lib/static -ljinja2cpp -L usr/local/lib -lboost_system -lpthread -o currency_converter
 ---> Running in bdbf146fe3b5
currency_converter.cpp:29:10: fatal error: nlohmann/json.hpp: No such file or directory
 #include <nlohmann/json.hpp>
          ^~~~~~~~~~~~~~~~~~~
compilation terminated.

And the Dockerfile itself is:

FROM ubuntu:18.04
WORKDIR /app
COPY /scripts /styles index.html currency_converter.cpp /app/
RUN apt-get update \
  && apt-get install -y git \
                        g++ \
                        build-essential \
                        make \
                        wget \
                        cmake
RUN wget https://dl.bintray.com/boostorg/release/1.68.0/source/boost_1_68_0.tar.bz2 \
    && tar -xjf boost_1_68_0.tar.bz2 \
    && rm -rf boost_1_68_0.tar.bz2 \
    && cd boost_1_68_0 \
    && ./bootstrap.sh \ 
    && ./b2 install
RUN git clone https://github.com/flexferrum/jinja2cpp \ 
    && cd jinja2cpp \
    && git submodule -q update --init \ 
    && mkdir build \ 
    && cd build \
    && cmake .. -DCMAKE_INSTALL_PREFIX=../install \
    && cmake --build . --target all
RUN git clone https://github.com/nlohmann/json
RUN g++ -std=c++14 -Wall -pedantic -I app/jinja2cpp/install/include -I app/json/single_include -I /usr/local/include/ -I app/jinja2cpp/thirdparty/nonstd/value-ptr-lite/include currency_converter.cpp -L app/jinja2cpp/install/lib/static -ljinja2cpp -L usr/local/lib -lboost_system -lpthread -o currency_converter
EXPOSE 80
ENV apikey <APIKEY>
ENV accesskey <ACCESSKEY>
CMD ["./currency_converter", "0.0.0.0", "8080", "."]

@nlohmann
Copy link
Owner

What is the content of app/json/single_include?

@DragonOsman
Copy link
Author

DragonOsman commented Oct 17, 2018

Let me check and get back to you (I'll update this comment).

Edit: Yes, the nlohmann directory is in there. And I think it has json.hpp in it, but I'll check just in case.

Edit2: As I thought, it's in there. So what do I do about this? It's saying the file isn't there, but it is.

Will it work if I do it like this: ./json/single_include?

@nlohmann
Copy link
Owner

Your compiler cannot find the JSON header. This has nothing to do with this library or Docker, but is a standard C++ problem. Can you try to compile a smaller program that only includes nlohmann/json.hpp?

@nlohmann nlohmann closed this as completed Nov 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state: needs more info the author of the issue needs to provide more details
Projects
None yet
Development

No branches or pull requests

3 participants