Click here to Skip to main content
15,884,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Good day, I'm trying to configure visual studio code well to learn Opengl I use Glad and GLFW libraries this is the project that works in Xcode but I hate Xcode and I want to make it go to Visual studio Code.

Git:

https://github.com/nio74/LearnOpeng_VSC.git



Now I want to use My MyClassShader Class to read shaders but I get this error:

C++
 Executing task: clang++ -std=c++17 -stdlib=libc++ -lglfw -lglew --include-directory=include/ --include-directory=build/ --include=include/glad.c -framework OpenGL -framework IOKit -framework Cocoa src/main.cpp -o build/helloworld --debug <

Undefined symbols for architecture x86_64:
  "MyClassShader::use()", referenced from:
      _main in main-9146b5.o
  "MyClassShader::MyClassShader(char const*, char const*)", referenced from:
      _main in main-9146b5.o
  "MyClassShader::setFloat(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, float) const", referenced from:
      _main in main-9146b5.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The terminal process "/bin/bash '-c', 'clang++ -std=c++17 -stdlib=libc++ -lglfw -lglew --include-directory=include/ --include-directory=build/ --include=include/glad.c -framework OpenGL -framework IOKit -framework Cocoa src/main.cpp -o build/helloworld --debug'" terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.


What I have tried:

This is the project that works in Xcode but I hate Xcode and I want to make it go to Visual studio Code.

this is tasks.json

C++
{
"version": "2.0.0",
    "tasks": [
		{
			"label": "HelloWorld",
			"type": "shell",
			"command": "clang++",
			"args": [
			
				
				"-std=c++17",
				"-stdlib=libc++",
				"-lglfw",
				"-lglew",
				"--include-directory=include/",
				"--include-directory=build/",
				"--include=include/glad.c",
				"-framework",
				"OpenGL",
				"-framework",
				"IOKit",
				"-framework",
				"Cocoa",
				"src/main.cpp",
				"-o",
				"build/helloworld",
				"--debug"
			],
			"group": {
				"kind": "build",
				"isDefault": true
			},
			"problemMatcher": []
		}
	]

}



do You have any idea? I change compilator?
Posted
Updated 19-Nov-20 5:23am
Comments
[no name] 19-Nov-20 10:28am    
"Love-hate" (working) relationships are a low priority.

1 solution

It appears to me that the module containing MyClassShader is not being compiled or it is not part of the link process. Another possibility is you have not implemented its constructor and its use and setFloat methods.
 
Share this answer
 
Comments
Paolo Mazzon 19-Nov-20 16:15pm    
I'll try reinstall xcode,I'll let know

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900