Some beginners questions

Moderator: Moderator

Some beginners questions

Postby itsmeek0 » Thu Apr 11, 2013 7:17 pm

I am new to programming overall, especially with the use of C++ and API. Im reading over how to login on forexconnect however I dont quite understand.

Do I need to have microsoft visual studio 2010 or some other IDE?
Can I just use a C++ compiler?
Where exactly does ForexConnect API need to be installed?

Can someone provide sample code on how to log into the server?

#include <iostream>
#include <windows.h>
#include "ForexConnect.h"
main ()
{
using namespace std;
class CSessionStatusListener : public IO2GSessionStatus {...}
IO2GSession *pSession = CO2GTransport::createSession();
CSessionStatusListener *sessionStatusListener = new CSessionStatusListener(&log, pSession, &oLoginData);
pSession->subscribeSessionStatus(sessionStatusListener);
ResponseListener *responseListener = new ResponseListener(&log, &responseQueue);
pSession->subscribeResponse(responseListener);
pSession->login("", "", "http://www.fxcorporate.com/Hosts.jsp", "Demo");
}

Is this all the code that is necessary besides inputting the log-in information and correct server URL once all installations have been properly taken care of?

Can you please provide some resources for me to learn from?

Thank you.
itsmeek0
 
Posts: 1
Joined: Thu Apr 11, 2013 7:10 pm

Re: Some beginners questions

Postby sunshine » Tue Apr 16, 2013 4:59 am

Hi itsmeek0,

itsmeek0 wrote:Do I need to have microsoft visual studio 2010 or some other IDE?
Can I just use a C++ compiler?

You can use any IDE that includes code editor, complier and linker.
But it's better to use Microsoft Visual Studio or Microsoft Visual C++ Express.
itsmeek0 wrote:Where exactly does ForexConnect API need to be installed?

It can be installed to any folder.

itsmeek0 wrote:Can someone provide sample code on how to log into the server?

Please find the login sample in the standard samples set provided with the ForexConnect. By default the path is:
C:\Program Files\Candleworks\ForexConnectAPI-1-3-0\samples\cpp\NonTableManagerSamples\Login

itsmeek0 wrote:Can you please provide some resources for me to learn from?

Please refer to the ForexConnect documentation:
http://www.fxcorporate.com/help/CPlusPl ... ntent.html
See also samples here:
http://www.fxcodebase.com/wiki/index.ph ... in_C%2B%2B
sunshine
 

Re: Some beginners questions

Postby jsotor » Mon Dec 23, 2013 8:30 am

Hi there.

I downloaded the samples and tried to compile them with g++/gcc 4.7.1 (I'm using codeblocks 12.11, ), and I got serveral errors.

I had to change:
Code: Select all
valuemap->setString(OrderType, O2G2::Order::TrueMarketOpen);

to:
Code: Select all
valuemap->setString(OrderType, O2G2::Orders::TrueMarketOpen);


Any call to:
Code: Select all
O2G2Ptr<IO2GResponse> response = loginRules->getTableRefeshResponse(---whatever----);

throws this error:
'class IO2GLoginRules' has no member named 'getTableRefeshResponse'


I changed it to:
Code: Select all
O2G2Ptr<IO2GResponse> response = loginRules->getTableRefreshResponse(---whatever----);


and the error stopped.

Now, that's odd, because documentation states this:

http://www.fxcodebase.com/documents/For ... Rules.html

class IO2GLoginRules

Parents
IAddRef
Brief

The interface provides information about the rules used during the login in the currently established session.

Details

To get an instance of this object, please use the IO2GSession::getLoginRules() method.

Please note that the session object must be successfully logged in to get the login rules.

Public Methods
getPermissionChecker Gets an instance of the permission checker.

getSystemPropertiesResponse Gets a response for the system properties received during the login.

getTableRefeshResponse Gets a response for the table refresh command automatically executed during the login.

getTradingSettingsProvider Gets an instance of the trading settings provider.

isTableLoadedByDefault Checks whether the table was loaded during the login.


Finally, I just can't make it work.
I get these errors:

Code: Select all
C:\Users\Jorge\AppData\Local\Temp\ccAgfd7S.o:ForexConnectSample.cpp:(.text$_ZN17
IO2GSessionStatusD2Ev[__ZN17IO2GSessionStatusD2Ev]+0xe): undefined reference to
`_imp___ZTV17IO2GSessionStatus'
C:\Users\Jorge\AppData\Local\Temp\ccAgfd7S.o:ForexConnectSample.cpp:(.text$_ZN17
IO2GSessionStatusD2Ev[__ZN17IO2GSessionStatusD2Ev]+0x1d): undefined reference to
 `_imp___ZN7IAddRefD2Ev'
C:\Users\Jorge\AppData\Local\Temp\ccAgfd7S.o:ForexConnectSample.cpp:(.text$_ZN17
IO2GSessionStatusD1Ev[__ZN17IO2GSessionStatusD1Ev]+0xe): undefined reference to
`_imp___ZTV17IO2GSessionStatus'
C:\Users\Jorge\AppData\Local\Temp\ccAgfd7S.o:ForexConnectSample.cpp:(.text$_ZN17
IO2GSessionStatusD1Ev[__ZN17IO2GSessionStatusD1Ev]+0x1d): undefined reference to
 `_imp___ZN7IAddRefD2Ev'
C:\Users\Jorge\AppData\Local\Temp\ccAgfd7S.o:ForexConnectSample.cpp:(.text$_ZN20
IO2GResponseListenerD2Ev[__ZN20IO2GResponseListenerD2Ev]+0xe): undefined referen
ce to `_imp___ZTV20IO2GResponseListener'
C:\Users\Jorge\AppData\Local\Temp\ccAgfd7S.o:ForexConnectSample.cpp:(.text$_ZN20
IO2GResponseListenerD2Ev[__ZN20IO2GResponseListenerD2Ev]+0x1d): undefined refere
nce to `_imp___ZN7IAddRefD2Ev'
C:\Users\Jorge\AppData\Local\Temp\ccAgfd7S.o:ForexConnectSample.cpp:(.text$_ZN20
IO2GResponseListenerD1Ev[__ZN20IO2GResponseListenerD1Ev]+0xe): undefined referen
ce to `_imp___ZTV20IO2GResponseListener'
C:\Users\Jorge\AppData\Local\Temp\ccAgfd7S.o:ForexConnectSample.cpp:(.text$_ZN20
IO2GResponseListenerD1Ev[__ZN20IO2GResponseListenerD1Ev]+0x1d): undefined refere
nce to `_imp___ZN7IAddRefD2Ev'
C:\Users\Jorge\AppData\Local\Temp\ccAgfd7S.o:ForexConnectSample.cpp:(.text$_ZN6C
MyAppC1Ev[__ZN6CMyAppC1Ev]+0x3e): undefined reference to `_imp___ZN17IO2GSession
StatusC2Ev'
C:\Users\Jorge\AppData\Local\Temp\ccAgfd7S.o:ForexConnectSample.cpp:(.text$_ZN6C
MyAppC1Ev[__ZN6CMyAppC1Ev]+0x54): undefined reference to `_imp___ZN20IO2GRespons
eListenerC2Ev'
C:\Users\Jorge\AppData\Local\Temp\ccAgfd7S.o:ForexConnectSample.cpp:(.text$_ZN6C
MyApp18onRequestCompletedEPKcP12IO2GResponse[__ZN6CMyApp18onRequestCompletedEPKc
P12IO2GResponse]+0x419): undefined reference to `VariantTimeToSystemTime@12'
C:\Users\Jorge\AppData\Local\Temp\ccAgfd7S.o:ForexConnectSample.cpp:(.text$_ZN6C
MyApp15onTablesUpdatesEP12IO2GResponse[__ZN6CMyApp15onTablesUpdatesEP12IO2GRespo
nse]+0x39e): undefined reference to `VariantTimeToSystemTime@12'
C:\Users\Jorge\AppData\Local\Temp\ccAgfd7S.o:ForexConnectSample.cpp:(.text$_ZN6C
MyApp3runEv[__ZN6CMyApp3runEv]+0x3c): undefined reference to `_imp___ZN13CO2GTra
nsport13createSessionEv'
collect2.exe: error: ld returned 1 exit status


What library I'm missing?
jsotor
 
Posts: 32
Joined: Mon Nov 21, 2011 9:24 am

Re: Some beginners questions

Postby Gennadiy » Tue Dec 24, 2013 12:22 am

Hello jsotor,

Could you please answer the following questions? It will allow us to better understand your problem and help you resolve it faster and more efficiently.

Thus, when posting issues, please specify your:
1) ForexConnect API version.
2) Platform (Windows, Linux, etc.).
3) Programming language (С++, Java, etc.).
4) Server name (MiniReal, GBPDemo, etc.).
5) Account type (Real, Demo, or MetaTrader).

Thank you.
Gennadiy
 

Re: Some beginners questions

Postby jsotor » Sat Dec 28, 2013 3:47 pm

Gennadiy wrote:Hello jsotor,

Could you please answer the following questions? It will allow us to better understand your problem and help you resolve it faster and more efficiently.

Thus, when posting issues, please specify your:
1) ForexConnect API version.
2) Platform (Windows, Linux, etc.).
3) Programming language (С++, Java, etc.).
4) Server name (MiniReal, GBPDemo, etc.).
5) Account type (Real, Demo, or MetaTrader).

Thank you.



Hi, thanks for your reply:

1) ForexConnect API version.
ForexConnectAPI-1.3.0-win64

2) Platform (Windows, Linux, etc.).
Windows 7

3) Programming language (С++, Java, etc.).
C++

4) Server name (MiniReal, GBPDemo, etc.).
5) Account type (Real, Demo, or MetaTrader).

I was expecting to test the ForexConnect API with a demo account, but I couldn't compile the samples, so I'm not in position to give you a valid answer to 4 and 5.


-----
I've been searching for info and the problem seems to be that g++ uses ".a" library files and VS C++ uses ".lib" library files, and they are not compatible for several reasons.

Is it possible to have a ForexConnect.a library?
jsotor
 
Posts: 32
Joined: Mon Nov 21, 2011 9:24 am

Re: Some beginners questions

Postby jsotor » Tue Dec 31, 2013 11:39 am

Another question:

What versions of Visual Studio do I have to use?

I installed VS Express 2013 and got this log when I tried to open the snl file.

What should I do?

I don't want to buy a VS Studio license. It makes no sense to my needs.
Attachments
UpgradeLog.rar
(13.7 KiB) Downloaded 883 times
jsotor
 
Posts: 32
Joined: Mon Nov 21, 2011 9:24 am

Re: Some beginners questions

Postby Gennadiy » Mon Jan 06, 2014 6:03 am

Hello jsotor,

Could you please clarify the target platform of your application?
As we understood, you want to use API for Linux on Windows machine.
Only way to use ForexConnect with non-msvc compiler on Windows is to use C-wrapper (It was discussed here).
The main problem using ForexConnect with different compiler on Windows is name mangling.
You can read about mangling here and here.

Visual Studio 2005 is a minimal Visual Studio version for samples (open sample project file *.vcproj).
Gennadiy
 


Return to ForexConnect API

Who is online

Users browsing this forum: No registered users and 3 guests