Use function from other Project?

Use function from other Project?

daniel_gearloose
Enthusiast Enthusiast
615 Views
7 Replies
Message 1 of 8

Use function from other Project?

daniel_gearloose
Enthusiast
Enthusiast

Problem:

I create 2 Arx files and in file A I have a function in a cpp and an h for it. With a class. Here is the code.

 

cpp-Datei (HALLO.CPP)
#include "StdAfx.h"
#include "HALLO.h"

void SAY::HALLO()
{
	acutPrintf(_T("\nHALLO"));
}

h-Datei (HALLO.H)
#ifndef HALLO_H
#define HALLO_H

class SAY
{
public:
	void HALLO();
protected:
};

#endif

 

In the same project file this works with:

 

SAY SAY;
SAY.HALLO();

 

 

But I would like to call the function from file B in the acrxEntryPoint.

I used:

 

#include "..\HALLO\HALLO.h"

...

SAY SAY;
SAY.HALLO();

 

 

 

but when I compile it spits out a fatal error LNK1120: 1 unresolved externals. Why? Or how do I have to call the function then?

 

0 Likes
616 Views
7 Replies
Replies (7)
Message 2 of 8

daniel_cadext
Advisor
Advisor

yeah, you have to link them.

kind of a hack, but you can use acedInvoke to pass data between two loaded arx modules, just as you can call a lisp function from arx. 

 

Python for AutoCAD, Python wrappers for ARX https://github.com/CEXT-Dan/PyRx
0 Likes
Message 3 of 8

daniel_gearloose
Enthusiast
Enthusiast

Sorry, you got me wrong. I ment from another Project in same Solution. I can't understand why this is a Problem.

Maybe anything with linking? But it is also nice to know that acedInvoke can call ARX-Commands. From calling Lisp commands I heard and used it once in C#.

0 Likes
Message 4 of 8

hbxiaogui
Advocate
Advocate

I think you should link Hello.lib to the caller project.

0 Likes
Message 5 of 8

daniel_gearloose
Enthusiast
Enthusiast

hmmm.... i tryed that... ok, i will try it again...

0 Likes
Message 6 of 8

daniel_gearloose
Enthusiast
Enthusiast

LINK : fatal error LNK1181: cannot open input file 'Hello.lib'

0 Likes
Message 7 of 8

hbxiaogui
Advocate
Advocate
I don't know what your project's name is which contains HALLO.h, so just call it Hello, maybe it is a wrong name, you must change it to correct.
You can add to code as below to the top in your file B, change the full path to the real .
#pragma comment(lib,"C:\\Test\\ProjectName.lib")
0 Likes
Message 8 of 8

tbrammer
Advisor
Advisor

If you want to call a function that is implemented in module A from a different module B then module A must export the function. Otherwise it is only callable in A internally. The same holds for the usage of classes.

It's a bit tricky in C++. I recommend to read this:

 


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

0 Likes