#Needing help to fix my code up

96 messages · Page 1 of 1 (latest)

plain kiln
#

Long story short I had 5 people help me with some code today

Which means code traded hands 5 different times and am in need of help because even CL the ide you all tell me to use is saying I'm missing stuff and I thought I dealt with this but I was wrong. I guess. I cant seem to instal curl for the life of me its so weird.

errant galleonBOT
#

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.

plain kiln
#
//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 function main': 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.
sick remnant
#

you can just use gcc from command line

plain kiln
#

oh what is the command to do so

sick remnant
#

hold windows key and press r, type cmd and press enter

plain kiln
#

yeah I mean what do I type in that

sick remnant
#

first go in your project folder using cd command and then just type
gcc yourfile.c -o output.exe -Iyour_include_directory

plain kiln
#

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

past otter
#

Install the curl dev package in msys2

plain kiln
#

already did bruv

#

tbf that was the one thing I didnt show

past otter
#

That's not the msys2 location

plain kiln
#

msys2?

past otter
#

Install it using pacman inside msys2

plain kiln
past otter
#

This is where msys2 is

#

You need to use the msys2 shell

plain kiln
#

aight

past otter
#

Let me find the package name, just a sec

plain kiln
past otter
#

Forget that

#

Run this in the msys2 shell: pacman -S libcurl-devel

#

on msys2.org it's referred to as "UCRT64 environment"

plain kiln
#

install it?

past otter
#

You install and update packages in this thing, with pacman which is a package manager

#

Install a package called libcurl-devel

plain kiln
#

I just ran the code you sent in chat

past otter
#

In the msys2 terminal window?

plain kiln
#

yeah

#

what else should I do?

#

you there @past otter ?

past otter
#

Try building your code now

plain kiln
past otter
#

Well where's the actual output

#

Is there none?

plain kiln
#

none

past otter
#

Show me what the msys2 terminal printed when you installed libcurl-devel

plain kiln
#

should I use?

past otter
#

Stop jumping to unrelated conclusions

plain kiln
past otter
#

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

plain kiln
past otter
#

Why is it now trying cl.exe

plain kiln
#

no idea

past otter
#

Try installing clang: pacman -S clang

plain kiln
#

alright

past otter
#

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

plain kiln
#

took a bit

past otter
#

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

plain kiln
#

still isnt working :/

past otter
#

Ok 😦

plain kiln
#

tbf this is why I have open up 3 tickets and talked to 7ish different people about this

past otter
#

Well, i don't have any windows environment set up now, not much to go on just yet

plain kiln
#

everyone here uses linux for easier setup lol

#

Im a windows guy

#

Heres what CL says

#

not vs code

past otter
#

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?

plain kiln
#

No Clion

past otter
#

Oh it's CLion. Never used it

plain kiln
#

I can compile everything that doesnt have a curl

#

So I'm very confused

past otter
#

It's not using msys2 as the environment

#

Google for clion libcurl

plain kiln
#

oh I tried on vs code and clion

plain kiln
plain kiln
past otter
#

Yeah that's the problem and known

#

Google for clion libcurl

plain kiln
#

redownload it?

past otter
#

GOOGLE

plain kiln
#

also thats vs code 💀

past otter
#

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

plain kiln
#

alright