I try to compile my C code in Visual studio but everytime I get the following error: undefined reference to ... I have to add -lgdiplus-lgdi32
to my compiler/linker options. How can I do this in Visual Studio?
This is a part of my task.json file:
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe",
"-lgdiplus",
"-lgdi32"
],
CodePudding user response:
- Right click on yout project and open the "Linker/Input" property page.
- Under "Additional Dependencies" enter "gdiplus-lgdi32.lib".
- If necessary, add the directory of the library to "Additional Library Directories".
More details can be found here.
CodePudding user response:
Assuming you're under linux(otherwise the process only shows different paths/compilers)
Under the .vscode folder, there should be a task.json
file.
You should find something similar to:
"command": "/usr/bin/g ",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
Add your arguments to the argument list, enjoy
If there's no file named like that nor you have the folder .vscode
in your workspace, click F5
and follow the instructions, and this will generate the necessary files for you.