#Needing help to fix my code up
96 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
//Code I'm tryna run
#include <stdio.h>
#include <stdlib.h>
#include <curl/curl.h>
int main() {
CURL *curl;
CURLcode res;
curl_global_init(CURL_GLOBAL_ALL);
curl = curl_easy_init();
if (curl) {
char* apiEndpoint = "dgb";
curl_easy_setopt(curl, CURLOPT_URL, apiEndpoint);
res = curl_easy_perform(curl);
if (res != CURLE_OK)
fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
curl_easy_cleanup(curl);
}
// Cleanup global curl resources
curl_global_cleanup();
return 0;
}
c_app_properties.json
{
"configurations": [
{
"name": "windows-gcc-x64",
"includePath": [
"${workspaceFolder}/**",
"C:/Users/robot/OneDrive/Desktop/DGBS/curl/include"
],
"compilerPath": "C:/msys64/ucrt64/bin/gcc.exe",
"cStandard": "${default}",
"cppStandard": "${default}",
"intelliSenseMode": "windows-gcc-x64",
"compilerArgs": [
"-IC:/Users/robot/OneDrive/Desktop/DGBS/curl/include"
]
}
],
"version": 4
}```
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "C/C++ Runner: Debug Session",
"type": "cppdbg",
"request": "launch",
"preLaunchTask": "Build",
"args": [],
"stopAtEntry": false,
"externalConsole": true,
"cwd": "${workspaceFolder}",
"program": "${workspaceFolder}/build/Debug/outDebug",
"MIMode": "gdb",
"miDebuggerPath": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
Error Messages:
CL:
fatal error: curl/curl.h: No such file or directory
3 | #include <curl/curl.h>
| ^~~~~~~~~~~~~
compilation terminated.
VS CODE:
- The terminal process terminated with exit code: -1.
- Terminal will be reused by tasks, press any key to close it.
- Executing task: C/C++: gcc.exe build active file
Starting build...
C:/msys64/ucrt64/bin/gcc.exe -fdiagnostics-color=always -g C:\Users\robot\OneDrive\Desktop\DGBS\api.c -o C:\Users\robot\OneDrive\Desktop\DGBS\api.exe -IC:/Users/robot/OneDrive/Desktop/DGBS/curl/include
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\robot\AppData\Local\Temp\cc0hZtfm.o: in functionmain': C:/Users/robot/OneDrive/Desktop/DGBS/api.c:10: undefined reference to__imp_curl_global_init'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/robot/OneDrive/Desktop/DGBS/api.c:11: undefined reference to__imp_curl_easy_init' C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/robot/OneDrive/Desktop/DGBS/api.c:19: undefined reference to__imp_curl_easy_setopt'
- The terminal process terminated with exit code: -1.
you can just use gcc from command line
oh what is the command to do so
hold windows key and press r, type cmd and press enter
yeah I mean what do I type in that
first go in your project folder using cd command and then just type
gcc yourfile.c -o output.exe -Iyour_include_directory
Well I cant run an exe of code that isnt compiled
Thats what the whole purpose of this ticket is
CL and visual studio are so bugged
sighs
I could sleep and wake up to someone in here I guess
would be kind of lame
Install the curl dev package in msys2
That's not the msys2 location
msys2?
Install it using pacman inside msys2
alright
aight
Let me find the package name, just a sec
when I try searching in the bar all I find is the installation exe
Forget that
Run this in the msys2 shell: pacman -S libcurl-devel
on msys2.org it's referred to as "UCRT64 environment"
install it?
You install and update packages in this thing, with pacman which is a package manager
Install a package called libcurl-devel
I just ran the code you sent in chat
In the msys2 terminal window?
Try building your code now
none
Show me what the msys2 terminal printed when you installed libcurl-devel
should I use?
Stop jumping to unrelated conclusions
Ok that looks fine
If there's a way to get some extra info from vscode about what happens when you try to compile then that would help
Otherwise not much i can do with that popup window
Why is it now trying cl.exe
no idea
Try installing clang: pacman -S clang
alright
This is making me interested in starting up my windows 10 VM and having a look at msys2 again. It's been over 1 year since I even booted windows, so I don't know if I'll be actually doing that today
If I do then I'll see if I can figure out anything
Btw, the reason why I suggested installing clang is because clang has an MSVC compatibility frontend. So if MSYS2 has a working clang-cl then cl.exe should work
Except that it's clang pretending to be cl.exe so that windows codebases will build without changes in the build setup
Try now
still isnt working :/
Ok 😦
tbf this is why I have open up 3 tickets and talked to 7ish different people about this
Well, i don't have any windows environment set up now, not much to go on just yet
everyone here uses linux for easier setup lol
Im a windows guy
Heres what CL says
not vs code
Ok, so still not finding the include path
What do you mean by CL, isn't CL just the WindowsC compiler executable and not a graphical application?
Oh it's CLion. Never used it
oh I tried on vs code and clion
vsc
redownload it?
also thats vs code 💀
google and chatgpt both can give you better advice than me right now
Don't redownload or do anything that's based on a guess or throwing stuff at a wall
Find some info first
alright