0

I give an example very close to my code:

camera.h

#pragma once

#ifndef VCL_CAMERA_TRACKING_H
#define VCL_CAMERA_TRACKING_H

extern int x;
....
#endif

main.cpp

#include "camera.h"
...    
int x = 15;

b.cpp

#include "camera.h"
...
int example = 15;
int numFaces = 0;
...
if(numFaces<1) x = example;
...

when I build my project in VS10 I get "error LNK2001: unresolved external symbol "int x" (?x@@3HA) at b.cpp".

It is strange because I have declared x in camera.h and defined it at main.cpp

2

1 Answer 1

1

You have declared your symbol:

extern int x;

But you haven't defined your symbol anywhere. You need to put

int x;

In one of your source files.

1
  • I think VS started to melt down. I defined x in b.cpp instead of main.cpp and it seems ok. thnx though!
    – lestreinz
    Feb 6, 2015 at 10:32

Not the answer you're looking for? Browse other questions tagged or ask your own question.