EDSDK digital camera C++ problem

Write your question here.
Hi everyone. I have problem compiling the following code. I compile this code both in empty and console visual studio application. I appreciate if you can help me correct my code.
error C2146: syntax error : missing ';' before identifier 'getFirstCamera'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2065: 'EdsCameraRef' : undeclared identifier
error C2065: 'camera' : undeclared identifier
fatal error C1903: unable to recover from previous error(s); stopping compilation

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
  #include <vector>
#include "Windows.h"
#include "EDSDK.h"
#include "EDSDKErrors.h"
#include "EDSDKTypes.h"
#include "stdafx.h"

EdsError getFirstCamera(EdsCameraRef *camera);
int _tmain(int argc, _TCHAR* argv[])
{   EdsError err=EDS_ERR_OK;
EdsCameraRef camera=NULL;
bool isSDKloaded=false;
// Initialize SDK
   err=EdsInitializeSDK();
if(err==EDS_ERR_OK)
{
isSDKloaded=true;
}

// Get first camera
if(err==EDS_ERR_OK)
{
err=getFirstCamera(&camera);
}
EdsOpenSession(camera);
EdsInt32 saveTarget = kEdsSaveTo_Host;
err = EdsSetPropertyData( camera, kEdsPropID_SaveTo, 0, 4, &saveTarget );
EdsSendCommand(camera, kEdsCameraCommand_TakePicture, 0);
EdsCloseSession(camera);
EdsTerminateSDK();
return 0;
}



EdsError getFirstCamera(EdsCameraRef *camera)
{
EdsError err=EDS_ERR_OK;
EdsCameraListRef cameraList=NULL;
EdsUInt32 count=0;
// Get camera list
err = EdsGetCameraList(&cameraList);
// Get number of cameras
if(err == EDS_ERR_OK)
{
    err = EdsGetChildCount(cameraList, &count);
    if(count == 0)
    {
        err = EDS_ERR_DEVICE_NOT_FOUND;
    }
}
// Get first camera retrieved
if(err == EDS_ERR_OK)
{
    err = EdsGetChildAtIndex(cameraList , 0 , camera);
}
// Release camera list
if(cameraList != NULL)
{EdsRelease(cameraList);
cameraList = NULL;
}
return err;
}
Last edited on
- Step 1.) is to delete Line 2, for better for worse, the author has included Windows.h in most of his headers

- Step 2.) RTFM: https://github.com/andrewrk/pyedsdk/blob/master/README . You'll notice that this author wants you to use MingW. I'll admit that I haven't dug around in the code and found an actual reason for this, but it's best to follow the original authors wishes unless you really know what you are doing. The inclusion of "stdafx.h" is a dead giveaway that you are using cl.exe.

Don't forget to link to that library after you run that python script to compile this.
Thank you very much for your reply.
I am newbie to C/C++ and low level computer programs .
I just want to control my Canon digital camera from my PC by a C++ code.
I found the code from:
http://stackoverflow.com/questions/16253029/take-pictures-and-save-images-to-my-c-photo-using-edsdk-2-10-use-c
I downloaded "EDSDK.h", "EDSDKErrors.h" and "EDSDKTypes.h" from internet, put them in the include directory and compiled via visual studio console application however it came up with the above errors.
I followed your prescription by correcting my code and running python and MingW, however, I could not install python properly. I guess python is not a necessity since EDSDK is supposed to be sufficient.
BTW, elimination of "stdafx.h" undefines _TCHAR in "main" function.
Once again I appreciate your time.
I never said to delete 'stdafx.h', I only pointed out that it is telling of what compiler you are using and that is not the compiler that the original author of this tool set targeted with his code. Since you're new I won't badger you with reasons about why you shouldn't rely on the '_TCHAR' macro since without context and experience they will seem anecdotal. Just keep in mind for the future that it isn't actually necessary and given enough time, on a large enough project, doing so will bite you in the ass.

I could not install python properly.

Do you mean that it appeared to be too much work and you thought it was unnecessary? Or that you actually couldn't get this to install? The former is understandable, albeit incorrect. The later is indicative of an actual problem.

Installing python will make it much easier to compile the library & DLL that you need to link to in order for this tool set to work. Strictly speaking, you are correct in that you don't actually need Python. However seeing as you are a beginner, you shouldn't make things more difficult than they already are for yourself. The fact that you are not linking to these files is at least part of the reason for the errors you are seeing.
Last edited on
Thanks again. I seriously followed your guidelines and hence I feel I got very close to finish.
I installed Python 3.5 (latest version)
which directory the author refers to in line 12, where he says "execute the following in this dir"?
https://github.com/andrewrk/pyedsdk/blob/master/README

When I execute "python setup.py build -c mingw32" in $(MINGW_ROOT)/lib
command prompt gives: "Python: can't open file 'setup.py': [error 2] no such file or directory"


I already installed Python, so what does he wanna say?
which directory the author refers to in line 12, where he says "execute the following in this dir"?

Legitimate question, I agree that was poorly worded on the author's part. He's referring to the directory that you have downloaded this tool set to. So where ever "EDSDK" is saved to is where you should run that command from.

When I execute "python setup.py build -c mingw32" in $(MINGW_ROOT)/lib
command prompt gives: "Python: can't open file 'setup.py': [error 2] no such file or directory"

My clarification above should resolve this.
It doesn't work.
I tried all directories.
BTW, I could not install the windows extension since it says it does not find the registry of Python.
Now I truly believe that this is not my job. Still I am not sure whether this is my PC problem or does not work at all.
Would you mind get control of my computer and do it?
You should be running: python setup.py build -c ming32 from the directory that 'setup.py' is stored in. You will likely have to use the fully qualified path for mingw32, enclose that path in double quotes when you enter it on the command line to avoid a common issue with whitespace in the path name.

Would you mind get control of my computer and do it?

Don't ever ask a stranger on a forum that you joined two days ago to do this.
Hi again and thanks.
I went through ur guidelines once again from the very beginning and now I m two steps forward. Thanks for teaching me.
Now the errors are:

gcc: error: win32_extension.cpp: No such file or directory
gcc: error: unrecognized command line option '-mno-cygwin'
gcc: fatal error: no input files
compilation terminated.
error: command 'gcc' failed with exit status 1


Moreover, where exactly shall I execute the following:

g++ -o test.exe test.cpp edsdk/Camera.cpp edsdk/Utils.cpp edsdk/Filesystem.cpp -lEDSDK -lole32

I mean, eventually, how should I run my cpp code (topic question)?
those errors correspond line 13 of:
https://github.com/andrewrk/pyedsdk/blob/master/README

I guess resolving that will get me done!
I'm glad we're making progress. I don't see where gcc is getting that file or command line argument from. If I have a minute later today I'll try building this on my system.
When I execute line 13 in that directory (Python extension for Win32) it occurs on command prompt.
Yes, sorry I should have explained. The author appears to be using an older version of MingW than you are. We need to find out what is trying to feed the deprecated argument of "-mno-cygwin" to GCC and delete it.

The setup.py itself is a little frustrating. The author is trying to use Python to accomplish what 'make' is intended to do. I don't know Python so I'm a bit slow reading it.
I truly appreciate helping me. I have learned a lot during our discussion.
It seems you chose a complicated case in cplusplus community!
Indeed, on a Raspberry Pi 2 I can not use a windows-based camera control driver. You and I are creating a driver from the very beginning.
This is a significant matter for me and hence I look forward to hearing from you.
Thanks!
Erm, let's take a step back for a minute. This SDK will enable your program to talk to the Canon driver, but it won't take the place of one.

Also
Indeed, on a Raspberry Pi 2 I can not use a windows-based camera control driver. You and I are creating a driver from the very beginning.

Is this the version of the Raspberry Pi that runs Windows 10? Because if you're running a non-Windows platform then this isn't going to work.
Topic archived. No new replies allowed.