Code review

Started by
11 comments, last by alvaro 7 years ago

obj\Debug\main.o||In function `ZN5WorldC1Ev':| C:\Users\chris\Documents\cat\main.cpp|69|undefined reference to `Block::Block(float, float, float, float)'|

Thos look to me like you're not linking in a .OBJ file built from your Block code. I'm not sure what environment you;re in (GCC on Windows, so it's not Visual Studio) but I suspect somewhere you need to add "block.cpp" to a project or something.

Stephen M. Webb
Professional Free Software Developer

Advertisement
All I did was install cb and started new project and tried to add my own class and errors but when I all the code in main problem sloved. I know it wrong to code in one file so help. Thanks

obj\Debug\main.o||In function `ZN5WorldC1Ev':| C:\Users\chris\Documents\cat\main.cpp|69|undefined reference to `Block::Block(float, float, float, float)'|

Thos look to me like you're not linking in a .OBJ file built from your Block code. I'm not sure what environment you;re in (GCC on Windows, so it's not Visual Studio) but I suspect somewhere you need to add "block.cpp" to a project or something.

obj\Debug\main.o||In function `ZN5WorldC1Ev':| C:\Users\chris\Documents\cat\main.cpp|69|undefined reference to `Block::Block(float, float, float, float)'|

Thos look to me like you're not linking in a .OBJ file built from your Block code. I'm not sure what environment you;re in (GCC on Windows, so it's not Visual Studio) but I suspect somewhere you need to add "block.cpp" to a project or something.
Yes I'm using codeblocks on windows 10 32bit,2gb,1.83g atom
Learn one thing at a time. If you want to learn how to have multi-file projects, create a new project. Make two .cpp files and one header file.

main.cpp:
#include "print_it.h"

int main() {
  print_it();
}
print_it.h:
#pragma once

void print_it();
print_it.cpp:
#include "print_it.h"

void print_it() {
  std::cout << "Hello, world!\n";
}

Figure out how to make that work in your environment. You'll have to add both .cpp files to your project, or something like that. Use Google to see how this is done in your particular environment.

Try compiling from the command line. Something like this should work:
> g++ -std=c++11 main.cpp print_it.cpp -o main.exe -Wall -Wextra -O3

This topic is closed to new replies.

Advertisement