question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG]: API compile request claims it can't find external header file

See original GitHub issue

Describe the bug

On this location: https://github.com/compiler-explorer/compiler-explorer/blob/main/docs/API.md#post-apicompilercompiler-idcompile---perform-a-compilation-1 it is described how one can use the API to trigger a build.

Indeed, this:

curl 'https://godbolt.org/api/compiler/g63/compile?options=-Wall' --data-binary $'#include <iostream> \n int main() {}'

works fine (please note the usage of the $'text\ntext' to get the required EOL)

However, when attempting to do the same using an external header file, it fails, claiming it can’t access the file (although the path is perfectly fine). For example, this fails:

curl 'https://godbolt.org/api/compiler/g63/compile?options=-Wall' --data-binary $'#include "https://raw.githubusercontent.com/skramm/homog2d/master/homog2d.hpp"\nint main() {}'

Output:

# Compilation provided by Compiler Explorer at https://godbolt.org/
<Compilation failed>
# Compiler exited with result code 1
Standard error:
<source>:1:79: fatal error: https://raw.githubusercontent.com/skramm/homog2d/master/homog2d.hpp: No such file or directory
 #include "https://raw.githubusercontent.com/skramm/homog2d/master/homog2d.hpp"
                                                                               ^
compilation terminated.

Steps to reproduce

Steps to reproduce: 1: run this in a (Linux) shell:

curl 'https://godbolt.org/api/compiler/g63/compile?options=-Wall' --data-binary $'#include "https://raw.githubusercontent.com/skramm/homog2d/master/homog2d.hpp"\nint main() {}'

Direct link to the file, for conveniency: https://raw.githubusercontent.com/skramm/homog2d/master/homog2d.hpp

Expected behavior

  • expected result: build starts and curl returns some data
  • observed result: curl return a message from CE, claiming it can not access the file.

Reproduction link

Not applicable

Screenshots

Not applicable

Operating System

Ubuntu 20.04.5

Browser version

No response

Issue Analytics

  • State:closed
  • Created 9 months ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
RubenRBScommented, Dec 19, 2022

(Leaving this open until we fix the docs yes)

Thanks for taking the time to file the original report with such detail btw, really appreciated 😃

1reaction
partoufcommented, Dec 19, 2022

BTW, any chance the API evolves so it gets possible to trigger a build using a shortlink? Say, something like GET /api/shortlinkinfo/<linkid>/build ? That would be a great feature!

It’s not likely as that will need to be maintained separately without us actually using it. It would involve simulating what the frontend does on a compile (“compile this as this human intended” - which is not obvious in the encoding of shortlinks - plus needing to implement the download for url includes and all other things we do) and then having to return an array of compilations instead of just 1.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Compile errors for external headers - Visual Studio Feedback
Basically, moving the two headers included with the ZIP file out of the project folder and into a folder in the include path...
Read more >
Top 10 C++ header file mistakes and how to fix them
Recommendation: Check your header filies by compiling them in isolation via a testMain.cpp that includes nothing but the header file under test.
Read more >
Where does Visual Studio look for C++ header files?
Visual Studio looks for headers in this order: In the current source directory. In the Additional Include Directories in the project properties (Project ......
Read more >
CLion fails to find some of my headers. Where does it search ...
CLion searches through the same places CMake does. Set the include_directories variable in CMake to provide the headers path to the IDE.
Read more >
Cannot find header files defined in compile_command that is ...
Create a header file in another directory that is not a parent of the project directory. Generate compile_command.json to have the header file...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found