TM1 C++ API issue
-
- Community Contributor
- Posts: 217
- Joined: Thu Aug 15, 2013 9:05 am
- OLAP Product: TM1
- Version: 10.2.1.1
- Excel Version: 14.0.6129.5000
TM1 C++ API issue
Hello to all,
I am trying to start the TM1 API for c++.
I am using Visual Studio 2010.
I have the header files included and the paths set in Visual Studio.
I have also set the PATH enviroment variable to the path of the header and .lib files.
But when I run my program, after a successful build, it gives me a System Error telling me that "The program can't start because TM1API.dll is missing from your computer. Try reinstalling the program to fix this problem"
I am sure the PATH enviroment variable is set, because when I run the command set "Path" I am given a return value of the PATH variable with the relevant TM1 links in there.
Has anybody come across this before? An error telling you that a dll is missing from visual studio c++?
As far as I am aware I have followed the documentation to the letter.
I am on TM1 10.2.1, on Windows.
Thanks.
Trevor
I am trying to start the TM1 API for c++.
I am using Visual Studio 2010.
I have the header files included and the paths set in Visual Studio.
I have also set the PATH enviroment variable to the path of the header and .lib files.
But when I run my program, after a successful build, it gives me a System Error telling me that "The program can't start because TM1API.dll is missing from your computer. Try reinstalling the program to fix this problem"
I am sure the PATH enviroment variable is set, because when I run the command set "Path" I am given a return value of the PATH variable with the relevant TM1 links in there.
Has anybody come across this before? An error telling you that a dll is missing from visual studio c++?
As far as I am aware I have followed the documentation to the letter.
I am on TM1 10.2.1, on Windows.
Thanks.
Trevor
-
- MVP
- Posts: 264
- Joined: Mon Nov 03, 2014 8:23 pm
- OLAP Product: TM1
- Version: 9.5.2 10.1 10.2 PA2
- Excel Version: 2016
Re: TM1 C++ API issue
Just so you know, IBM has been pushing their new REST api recently instead of the C api, but YMMV.TrevorGoss wrote:I am trying to start the TM1 API for c++.
As for your actual question, if you're trying to run your program from inside Visual Studio (debug, etc...) you'll need to make sure Visual Studio itself is running with the path set correctly. If this is the case but you're still struggling, Process Explorer (from microsoft) is capable of displaying the environment settings of any running program.
If you're not trying to run your program from inside Visual Studio, you can try the free Dependency Walker tool. This used to be shipped with VS 2005 and earlier.
-
- Community Contributor
- Posts: 217
- Joined: Thu Aug 15, 2013 9:05 am
- OLAP Product: TM1
- Version: 10.2.1.1
- Excel Version: 14.0.6129.5000
Re: TM1 C++ API issue
Indeed, I just could not find any place to start when it came to the REST api, the documentation seemed weaker for REST than it did for the c++ and Java api. Any links will be most appreciated.Just so you know, IBM has been pushing their new REST api recently instead of the C api, but YMMV.
I have managed to get it loaded now and I can run the functions in c++ for the TM1 api. It was rather strange, I had to bring across 4 dlls from the TM1 bin folder and palce them in the same directory as the exe file. VS kept telling me that a dll was missing, so I picked it from the TM1 folder and placed it in, after about 4 dll moves it worked.As for your actual question, if you're trying to run your program from inside Visual Studio (debug, etc...) you'll need to make sure Visual Studio itself is running with the path set correctly. If this is the case but you're still struggling, Process Explorer (from microsoft) is capable of displaying the environment settings of any running program.
If you're not trying to run your program from inside Visual Studio, you can try the free Dependency Walker tool. This used to be shipped with VS 2005 and earlier.
The issue I have now is that it will not find any admin servers, even though I am passing it the machine name. the code:
Code: Select all
TM1U hUser = 0;
TM1_INDEX iServerCount;
TM1_INDEX iServer;
CHAR * sDbName;
TM1V voDbHandle;
hUser = TM1SystemOpen();
std::cout << hUser << std::endl;
if(hUser)
{
//printf("you are in the first if"); // to test the if
TM1SystemAdminHostSet(hUser,"ABCDE12345");
iServerCount = TM1SystemServerNof( hUser);
std::cout << iServerCount << std::endl;
for (iServer = 1; iServer <= iServerCount; iServer++)
{
sDbName = TM1SystemServerName(hUser,iServer);
voDbHandle = TM1SystemServerHandle(hUser, sDbName);
if( voDbHandle)
{
std::cout << "CONNECTED:\t" << sDbName << std::endl;
}else
{
std::cout << "NOT CONNECTED:\t" << sDbName << std::endl;
}
}
TM1SystemClose( hUser );
}
else
{
std::cout << "Cannot connect to the API" <<std::endl;
}
Any ideas? Thanks Brian.
Trevor.
-
- Site Admin
- Posts: 6643
- Joined: Sun May 11, 2008 2:30 am
- OLAP Product: TM1
- Version: PA2.0.9.18 Classic NO PAW!
- Excel Version: 2013 and Office 365
- Location: Sydney, Australia
- Contact:
Re: TM1 C++ API issue
Just so you also know, I saw the REST API at the Cubewise Conference last week and it Rocks. Like. Hell. I've been having dreams about it ever since. Which is kinda sad when you think about it. And getting it to do some stuff is on my to do as soon as is possible list, though of course this is mitigated by the fact that we still have a chunk of our system on 9.5.2 and I have to get that over first.TrevorGoss wrote:Indeed, I just could not find any place to start when it came to the REST api, the documentation seemed weaker for REST than it did for the c++ and Java api. Any links will be most appreciated.Brian L wrote:Just so you know, IBM has been pushing their new REST api recently instead of the C api, but YMMV.
But just so you also also know, yes, there is indeed a paucity of documentation on it. This actually came up at the conference with someone asking a question on that, and the answer was that (a) there was stuff on Developerworks (which there is, but just disjointed fragments here and there) and (b) It is oData compliant and there is plenty of stuff out there on that. (Here, for example.) But make no mistake, the REST API is going to be a much steeper learning curve than any of the older APIs were, and also {sotto voce} there may be the odd bug in it given that it's an early release. But in terms of raw freaking power and speed, that thing looks to be The Business.
"To them, equipment failure is terrifying. To me, it’s 'Tuesday.' "
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.
-
- Community Contributor
- Posts: 217
- Joined: Thu Aug 15, 2013 9:05 am
- OLAP Product: TM1
- Version: 10.2.1.1
- Excel Version: 14.0.6129.5000
Re: TM1 C++ API issue
I also have heard good things about it, which is why I want to find out more, plus...c++ gives me a headache lol.Just so you also know, I saw the REST API at the Cubewise Conference last week and it Rocks. Like. Hell.
Thanks for the links I will investigate and use the tutorials.
Trevor
-
- Site Admin
- Posts: 6643
- Joined: Sun May 11, 2008 2:30 am
- OLAP Product: TM1
- Version: PA2.0.9.18 Classic NO PAW!
- Excel Version: 2013 and Office 365
- Location: Sydney, Australia
- Contact:
Re: TM1 C++ API issue
No problem. Something else that you may find useful - I saw it being used in the demonstrations but haven't downloaded it myself yet - is the Postman tool which can be found here.TrevorGoss wrote:I also have heard good things about it, which is why I want to find out more, plus...c++ gives me a headache lol.Just so you also know, I saw the REST API at the Cubewise Conference last week and it Rocks. Like. Hell.
Thanks for the links I will investigate and use the tutorials.
"To them, equipment failure is terrifying. To me, it’s 'Tuesday.' "
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.
-
- Community Contributor
- Posts: 217
- Joined: Thu Aug 15, 2013 9:05 am
- OLAP Product: TM1
- Version: 10.2.1.1
- Excel Version: 14.0.6129.5000
Re: TM1 C++ API issue
ThanksNo problem. Something else that you may find useful - I saw it being used in the demonstrations but haven't downloaded it myself yet - is the Postman tool which can be found here.
-
- MVP
- Posts: 264
- Joined: Mon Nov 03, 2014 8:23 pm
- OLAP Product: TM1
- Version: 9.5.2 10.1 10.2 PA2
- Excel Version: 2016
Re: TM1 C++ API issue
This can often be caused by an SSL error. If you haven't yet, try copying the entire "ssl" folder from the TM1 bin directory into the same place as the dlls (or try disabling SSL on BOTH admin server and tm1 server).TrevorGoss wrote: The issue I have now is that it will not find any admin servers, even though I am passing it the machine name.
-
- Community Contributor
- Posts: 217
- Joined: Thu Aug 15, 2013 9:05 am
- OLAP Product: TM1
- Version: 10.2.1.1
- Excel Version: 14.0.6129.5000
Re: TM1 C++ API issue
That worked, excellent thanks.This can often be caused by an SSL error. If you haven't yet, try copying the entire "ssl" folder from the TM1 bin directory into the same place as the dlls
Have you ever connected to a TM1 server with this API?
My code:
Code: Select all
TM1SystemAdminHostSet(hUser,"ABCDE12345");
iServerCount = TM1SystemServerNof( hUser);
std::cout << iServerCount << std::endl;
for (iServer = 1; iServer <= iServerCount; iServer++)
{
sDbName = TM1SystemServerName(hUser,iServer);
voDbHandle = TM1SystemServerHandle(hUser, sDbName);
std::cout << voDbHandle << std::endl;
if( voDbHandle)
{
std::cout << "CONNECTED:\t" << sDbName << std::endl;
}else
{
std::cout << "NOT CONNECTED:\t" << sDbName << std::endl;
}
}
TM1SystemClose( hUser );
Code: Select all
std::cout << "NOT CONNECTED:\t" << sDbName << std::endl;
Thanks Brian.
Trevor
-
- MVP
- Posts: 264
- Joined: Mon Nov 03, 2014 8:23 pm
- OLAP Product: TM1
- Version: 9.5.2 10.1 10.2 PA2
- Excel Version: 2016
Re: TM1 C++ API issue
Unless I'm missing some code, you haven't actually attempted to connect (log in) to the server. You'll only get a handle back from TM1SystemServerHandle if you've already logged in. For the C API, log in and connect are pretty much synonymous.TrevorGoss wrote:So it is not connecting to the TM1 servers, any ideas?r
-
- Community Contributor
- Posts: 217
- Joined: Thu Aug 15, 2013 9:05 am
- OLAP Product: TM1
- Version: 10.2.1.1
- Excel Version: 14.0.6129.5000
Re: TM1 C++ API issue
Hello again Brian, thanks for the reply.
Was trying to connect (login) to the server, I have a handle call and then an if statement checking if handle is true (connected), is there anything else required?
By the way, my source for this code was the file "GetListofServers.cpp" in the samplecode/cpp fodlers of the tm1api path.
My servers are also on run state 5, if this makes a difference.
Thanks.
I would think this code:Unless I'm missing some code, you haven't actually attempted to connect (log in) to the server. You'll only get a handle back from TM1SystemServerHandle if you've already logged in.
Code: Select all
for( iServer = 1; iServer <= iServerCount; iServer++)
{
sDbName = TM1SystemServerName( hUser, iServer );
voDbHandle = TM1SystemServerHandle( hUser, sDbName );
if ( voDbHandle ){
std::cout << "Connected: " << sDbName << std::endl;
}else{
std::cout << "Not Connected: " << sDbName << std::endl;
}
}
TM1SystemClose( hUser );
By the way, my source for this code was the file "GetListofServers.cpp" in the samplecode/cpp fodlers of the tm1api path.
My servers are also on run state 5, if this makes a difference.
Thanks.
-
- MVP
- Posts: 2835
- Joined: Tue Feb 16, 2010 2:39 pm
- OLAP Product: TM1, Palo
- Version: Beginning of time thru 10.2
- Excel Version: 2003-2007-2010-2013
- Location: Atlanta, GA
- Contact:
Re: TM1 C++ API issue
Where is the code for logging in? The example you used just get's a list of available servers, it doesn't actually log in. You have to log in with a call to the TM1SystemServerConnect function. A quick Google search returned this link: http://www-01.ibm.com/support/knowledge ... inC_N700AA
-
- Community Contributor
- Posts: 217
- Joined: Thu Aug 15, 2013 9:05 am
- OLAP Product: TM1
- Version: 10.2.1.1
- Excel Version: 14.0.6129.5000
Re: TM1 C++ API issue
Hello Tom, thanks for the response.
I have copied the code from that link in a new function and it returns no errors, but I am not sure if it was successful, my code:
The last bit of code is to check if I have connected, I was hoping that if the vServerObject is true, I have connected and I do receive a "yes" when the code is run.
Is it also possible to log into runstate 5? The documentation only (AFAIK) talks about run state 1,2 or 3.
Thanks.
I have copied the code from that link in a new function and it returns no errors, but I am not sure if it was successful, my code:
Code: Select all
char * sAdminHost = "ABCDE12345";
TM1SystemAdminHostSet (hUser,(CHAR *) sAdminHost);
//
// Create Value Pools from strings so that we can log in.
//
hPool1 = TM1ValPoolCreate(hUser);
hPool2 = TM1ValPoolCreate(hUser);
char * sUserName = "a";
char * sServerName = "Server";
char * sPassword = "";
TM1V vUserName = TM1ValString(hPool1, (CHAR *) sUserName, 10);
TM1V vServerName = TM1ValString(hPool1, (CHAR *) sServerName, 10);
TM1V vPassword = TM1ValString(hPool1, (CHAR *) sPassword, 10);
//
// TM1SystemServerConnect logs in to TM1. This function returns
// a TM1 server object
//
TM1V vServerObject = TM1SystemServerConnect(hPool1, vServerName,
vUserName, vPassword);
TM1V vsServerName = TM1ObjectPropertyGet (hPool2, vServerObject, TM1ObjectName()
);
sServerName = (char *) TM1ValStringGet(hUser, vsServerName);
if(vServerObject)
{
std::cout << "yes" << std::endl;
}
Is it also possible to log into runstate 5? The documentation only (AFAIK) talks about run state 1,2 or 3.
Thanks.
-
- Community Contributor
- Posts: 217
- Joined: Thu Aug 15, 2013 9:05 am
- OLAP Product: TM1
- Version: 10.2.1.1
- Excel Version: 14.0.6129.5000
Re: TM1 C++ API issue
Success!
I created code that gets the handle of the user and the server and then I test its connection:
Add this code to the bottom of my previous code and I will receive a "Connected" message to the screen, if I put a server name that does not exist, it fails, so some success.
I would still like to know if I can connect to TM1 servers in run state 5?
Thanks
I created code that gets the handle of the user and the server and then I test its connection:
Code: Select all
voDbHandle = TM1SystemServerHandle( hUser, sServerName );
if ( voDbHandle ){
std::cout << "Connected: " << sServerName << std::endl;
}else{
std::cout << "Not Connected: " << sServerName << std::endl;
}
I would still like to know if I can connect to TM1 servers in run state 5?
Thanks
-
- MVP
- Posts: 264
- Joined: Mon Nov 03, 2014 8:23 pm
- OLAP Product: TM1
- Version: 9.5.2 10.1 10.2 PA2
- Excel Version: 2016
Re: TM1 C++ API issue
The function is not documented for CAM login, but the following code should work.
(Note: you can find the function declaration in TM1API.H. This can be a good source of undocumented function names for the C API. The declaration doesn't explain what all the params are, but sometimes a little trial and error can go a long way.)
(Note: you can find the function declaration in TM1API.H. This can be a good source of undocumented function names for the C API. The declaration doesn't explain what all the params are, but sometimes a little trial and error can go a long way.)
Code: Select all
TM1V vArray[3];
TM1V vCAMarr;
char * sServerName = "Server";
TM1V vServerName = TM1ValString(hPool1, (CHAR *) sServerName, 0);
vArray[0] = TM1ValString(hPool1, (char*)sCAMNamespace, 0 );
vArray[1] = TM1ValString(hPool1, (char*)sUsername, 0 );
vArray[2] = TM1ValStringEncrypt(hPool1, (char*)sPassword, 0 );
vCAMarr = TM1ValArray( hPool1, vArray, 3 );
TM1V vServerObject = SystemServerConnectWithCAMNamespace(hPool1, vServerName, vCAMarr );
-
- Community Contributor
- Posts: 217
- Joined: Thu Aug 15, 2013 9:05 am
- OLAP Product: TM1
- Version: 10.2.1.1
- Excel Version: 14.0.6129.5000
Re: TM1 C++ API issue
I have got it working with CAM now thanks.
Thanks for your help, are there any "gotchas" or any other dodgy things that can come out of the C/C++ api?
Trevor.
Good idea, the intellisense can be helpful for undocumented functions aswell.(Note: you can find the function declaration in TM1API.H. This can be a good source of undocumented function names for the C API. The declaration doesn't explain what all the params are, but sometimes a little trial and error can go a long way.)
Thanks for your help, are there any "gotchas" or any other dodgy things that can come out of the C/C++ api?
Trevor.
-
- MVP
- Posts: 264
- Joined: Mon Nov 03, 2014 8:23 pm
- OLAP Product: TM1
- Version: 9.5.2 10.1 10.2 PA2
- Excel Version: 2016
Re: TM1 C++ API issue
There are a couple counter-intuitive quirks of the API that are documented.
http://www-01.ibm.com/support/knowledge ... ety_N704C3
This one is basically saying if you share user handles (gotten from SystemServerConnect) across multiple threads, the API will serialize the calls and only run one at a time.
http://www-01.ibm.com/support/knowledge ... ues_N707C7
This one is trickier to understand. Essentially the API will queue up all network traffic until you actually query the type or contents of a TM1V. Until then, the API will transparently queue up any requested API calls and send them to the server all at once. Even using return values from one function as a parameter to the next can be handled in a single network round trip (as long as you don't query the type or contents of the return value first).
That's all that comes to mind off the top of my head.
http://www-01.ibm.com/support/knowledge ... ety_N704C3
This one is basically saying if you share user handles (gotten from SystemServerConnect) across multiple threads, the API will serialize the calls and only run one at a time.
http://www-01.ibm.com/support/knowledge ... ues_N707C7
This one is trickier to understand. Essentially the API will queue up all network traffic until you actually query the type or contents of a TM1V. Until then, the API will transparently queue up any requested API calls and send them to the server all at once. Even using return values from one function as a parameter to the next can be handled in a single network round trip (as long as you don't query the type or contents of the return value first).
That's all that comes to mind off the top of my head.
-
- Community Contributor
- Posts: 217
- Joined: Thu Aug 15, 2013 9:05 am
- OLAP Product: TM1
- Version: 10.2.1.1
- Excel Version: 14.0.6129.5000
Re: TM1 C++ API issue
Thanks for these, I have managed to connect to the API which is what I wanted, now the rest is up to me and playing around.There are a couple counter-intuitive quirks of the API that are documented.
http://www-01.ibm.com/support/knowledge ... ety_N704C3
This one is basically saying if you share user handles (gotten from SystemServerConnect) across multiple threads, the API will serialize the calls and only run one at a time.
http://www-01.ibm.com/support/knowledge ... ues_N707C7
This one is trickier to understand. Essentially the API will queue up all network traffic until you actually query the type or contents of a TM1V. Until then, the API will transparently queue up any requested API calls and send them to the server all at once. Even using return values from one function as a parameter to the next can be handled in a single network round trip (as long as you don't query the type or contents of the return value first).
That's all that comes to mind off the top of my head.
Thanks.
-
- Community Contributor
- Posts: 217
- Joined: Thu Aug 15, 2013 9:05 am
- OLAP Product: TM1
- Version: 10.2.1.1
- Excel Version: 14.0.6129.5000
Re: TM1 C++ API issue
Hello again,
I thought I would post this question here rather than start a new post because of the topic.
I am trying to run a TI process via the C++ API, using the function TM1ProcessExecute. The TI I am using is just a flat file creation to test it.
My issue is that the TI takes no parameters, so the IBM documentation states
Has anyone fired a TI via the c++ API before? Did they come across this function? Does anyone have and ideas how to get past this issue?
Thanks.
Trevor.
I thought I would post this question here rather than start a new post because of the topic.
I am trying to run a TI process via the C++ API, using the function TM1ProcessExecute. The TI I am using is just a flat file creation to test it.
My issue is that the TI takes no parameters, so the IBM documentation states
but, in c++ (as far as I am aware) you cannot have array sizes of nothing, i.e. zero elements, so I do not see how I can fire this TI?A process with no parameters takes an array of zero elements
Has anyone fired a TI via the c++ API before? Did they come across this function? Does anyone have and ideas how to get past this issue?
Thanks.
Trevor.
-
- MVP
- Posts: 264
- Joined: Mon Nov 03, 2014 8:23 pm
- OLAP Product: TM1
- Version: 9.5.2 10.1 10.2 PA2
- Excel Version: 2016
Re: TM1 C++ API issue
The API is looking for a TM1V, not a C array. Thus you should be able to do something like
Code: Select all
TM1V empty;
TM1V params = TM1ValArray(pool, empty, 0);
TM1ProcessExecuteEx(pool, process, params );