All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [tpm2] Compiling/linking tpm2 application - undefined reference to Esys function
@ 2019-02-03 15:23 
  0 siblings, 0 replies; 4+ messages in thread
From:  @ 2019-02-03 15:23 UTC (permalink / raw)
  To: tpm2

[-- Attachment #1: Type: text/plain, Size: 3823 bytes --]

Thank you very much it indeed worked!

Is there any special reason for it to have to come after the source files?
I thought that the linker would create the symbols table and add any
"symbol" it finds out so that whenever they are needed they would be
substituted. (in this case, my program would add the "Esys_GetRandom" to
the table and then the linker would check the flag and get the
implementation for that function). I see it doesn't quite work like that,
any special reason or is just my misunderstanding?

Anyway, just to give the whole explanation the complete info of this
problem (if anyone has the same problem)

My gcc command for linking was

"g++ -Wall -g -pthread -std=c++11  -ltss2-esys -L/usr/local/lib/  -o
../../../bin/Developer Developer.o"

When i switched it to

"g++ -Wall -g -pthread -std=c++11 -o ../../../bin/Developer Developer.o
-ltss2-esys -L/usr/local/lib/"

It linked correctly.

Again thank you very much!

Fuchs, Andreas <andreas.fuchs(a)sit.fraunhofer.de> escreveu no dia domingo,
3/02/2019 à(s) 07:23:

> Hi Antonio,
>
> I think we would need to see the complete gcc command.
>
> But maybe a first hint: The -ltss2-esys must come AFTER the source file on
> commandline.
>
> Cheers,
> Andreas
>
> ------------------------------
> *From:* tpm2 [tpm2-bounces(a)lists.01.org] on behalf of António Ribeiro [
> antonio.ribeiro94(a)gmail.com]
> *Sent:* Sunday, February 03, 2019 03:06
> *To:* tpm2(a)lists.01.org
> *Subject:* [tpm2] Compiling/linking tpm2 application - undefined
> reference to Esys function
>
> Hello everyone,
>
> First of all, i am sorry to be bothering this mailing list with a doubt i
> think it should be quite obvious unfortunately, i am not being able to find
> out a solution to it. Also, i am not sure if this should go here or in the
> issues of the repositories. If this is not the right place i will gladly
> post it on github.
>
> I installed everything as said in github repos (tpm2-tss, tpm2-abrmd and
> tpm2-tools). I am trying to create an application (just a proof of concept)
> with tpm2 and the first thing i am trying to do is call a function from the
> library Esys (tss2/tss2_esys.h) to print a random number. Unfortunately,
> when i try to compile and link the application files the compiler/linker
> (gcc) says:
>
> *(if it is needed i can copy/paste the whole text)*
> *"undefined reference to `Esys_GetRandom'"*
>
> On the code, i am trying to make the same call that is made on tpm2-tools
> getrandom, so i dont think there is a problem with that call (and also it
> compiles correctly but doesn't link).
>
> I am using the flags i suppose are needed "-I/usr/local/include" for
> compilation (just to be sure) and "-L/usr/local/lib -ltss2-mu
> -ltss2-tcti-device -ltss2-sys -ltss2-esys" for the linking part (i also
> tried with the flags "-ltpm2sapi" which i found in another github repo. I
> was able to compile and use all the tools on the tpm2-tools repo, which
> makes me believe the problem is not in the libraries themselves but  any
> flags may be missing in my linking. Unfortunately, i tried with the flags i
> could get from the Makefile it has on tpm2-tools but same result.
>
> Can anyone tell me what am i doing wrong? Or at least point me in the
> right direction?
> The OS is Ubuntu 18.04.1 LTS (in VMWare Workstation if it makes any
> difference).
>
> Thank you very much;
>
> --
> António Ribeiro
> +351 916045500 | antonio.ribeiro94(a)gmail.com
> Masters in Computer Science & Engineering
> New University of Lisbon - Faculty of Science and Technology
>


-- 
António Ribeiro
+351 916045500 | antonio.ribeiro94(a)gmail.com
Masters in Computer Science & Engineering
New University of Lisbon - Faculty of Science and Technology

[-- Attachment #2: attachment.html --]
[-- Type: text/html, Size: 6825 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [tpm2] Compiling/linking tpm2 application - undefined reference to Esys function
@ 2019-02-03 19:23 Fuchs, Andreas
  0 siblings, 0 replies; 4+ messages in thread
From: Fuchs, Andreas @ 2019-02-03 19:23 UTC (permalink / raw)
  To: tpm2

[-- Attachment #1: Type: text/plain, Size: 4440 bytes --]

Linker goes from left to write, adds any unresolved symbol to the table and attempts to resolve it during the next library, adding any new symbols to the table.
If the table is not empty after the last object, it errors with the table...

Anyways, glad to have 1 more user join...
________________________________
From: António Ribeiro [antonio.ribeiro94(a)gmail.com]
Sent: Sunday, February 03, 2019 16:23
To: Fuchs, Andreas
Cc: tpm2(a)lists.01.org
Subject: Re: [tpm2] Compiling/linking tpm2 application - undefined reference to Esys function

Thank you very much it indeed worked!

Is there any special reason for it to have to come after the source files? I thought that the linker would create the symbols table and add any "symbol" it finds out so that whenever they are needed they would be substituted. (in this case, my program would add the "Esys_GetRandom" to the table and then the linker would check the flag and get the implementation for that function). I see it doesn't quite work like that, any special reason or is just my misunderstanding?

Anyway, just to give the whole explanation the complete info of this problem (if anyone has the same problem)

My gcc command for linking was

"g++ -Wall -g -pthread -std=c++11  -ltss2-esys -L/usr/local/lib/  -o ../../../bin/Developer Developer.o"

When i switched it to

"g++ -Wall -g -pthread -std=c++11 -o ../../../bin/Developer Developer.o -ltss2-esys -L/usr/local/lib/"

It linked correctly.

Again thank you very much!

Fuchs, Andreas <andreas.fuchs(a)sit.fraunhofer.de<mailto:andreas.fuchs(a)sit.fraunhofer.de>> escreveu no dia domingo, 3/02/2019 à(s) 07:23:
Hi Antonio,

I think we would need to see the complete gcc command.

But maybe a first hint: The -ltss2-esys must come AFTER the source file on commandline.

Cheers,
Andreas

________________________________
From: tpm2 [tpm2-bounces(a)lists.01.org<mailto:tpm2-bounces(a)lists.01.org>] on behalf of António Ribeiro [antonio.ribeiro94(a)gmail.com<mailto:antonio.ribeiro94(a)gmail.com>]
Sent: Sunday, February 03, 2019 03:06
To: tpm2(a)lists.01.org<mailto:tpm2(a)lists.01.org>
Subject: [tpm2] Compiling/linking tpm2 application - undefined reference to Esys function

Hello everyone,

First of all, i am sorry to be bothering this mailing list with a doubt i think it should be quite obvious unfortunately, i am not being able to find out a solution to it. Also, i am not sure if this should go here or in the issues of the repositories. If this is not the right place i will gladly post it on github.

I installed everything as said in github repos (tpm2-tss, tpm2-abrmd and tpm2-tools). I am trying to create an application (just a proof of concept) with tpm2 and the first thing i am trying to do is call a function from the library Esys (tss2/tss2_esys.h) to print a random number. Unfortunately, when i try to compile and link the application files the compiler/linker (gcc) says:

(if it is needed i can copy/paste the whole text)
"undefined reference to `Esys_GetRandom'"

On the code, i am trying to make the same call that is made on tpm2-tools getrandom, so i dont think there is a problem with that call (and also it compiles correctly but doesn't link).

I am using the flags i suppose are needed "-I/usr/local/include" for compilation (just to be sure) and "-L/usr/local/lib -ltss2-mu -ltss2-tcti-device -ltss2-sys -ltss2-esys" for the linking part (i also tried with the flags "-ltpm2sapi" which i found in another github repo. I was able to compile and use all the tools on the tpm2-tools repo, which makes me believe the problem is not in the libraries themselves but  any flags may be missing in my linking. Unfortunately, i tried with the flags i could get from the Makefile it has on tpm2-tools but same result.

Can anyone tell me what am i doing wrong? Or at least point me in the right direction?
The OS is Ubuntu 18.04.1 LTS (in VMWare Workstation if it makes any difference).

Thank you very much;

--
António Ribeiro
+351 916045500 | antonio.ribeiro94(a)gmail.com<mailto:antonio.ribeiro94(a)gmail.com>
Masters in Computer Science & Engineering
New University of Lisbon - Faculty of Science and Technology


--
António Ribeiro
+351 916045500 | antonio.ribeiro94(a)gmail.com<mailto:antonio.ribeiro94(a)gmail.com>
Masters in Computer Science & Engineering
New University of Lisbon - Faculty of Science and Technology

[-- Attachment #2: attachment.html --]
[-- Type: text/html, Size: 8296 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [tpm2] Compiling/linking tpm2 application - undefined reference to Esys function
@ 2019-02-03  7:22 Fuchs, Andreas
  0 siblings, 0 replies; 4+ messages in thread
From: Fuchs, Andreas @ 2019-02-03  7:22 UTC (permalink / raw)
  To: tpm2

[-- Attachment #1: Type: text/plain, Size: 2465 bytes --]

Hi Antonio,

I think we would need to see the complete gcc command.

But maybe a first hint: The -ltss2-esys must come AFTER the source file on commandline.

Cheers,
Andreas

________________________________
From: tpm2 [tpm2-bounces(a)lists.01.org] on behalf of António Ribeiro [antonio.ribeiro94(a)gmail.com]
Sent: Sunday, February 03, 2019 03:06
To: tpm2(a)lists.01.org
Subject: [tpm2] Compiling/linking tpm2 application - undefined reference to Esys function

Hello everyone,

First of all, i am sorry to be bothering this mailing list with a doubt i think it should be quite obvious unfortunately, i am not being able to find out a solution to it. Also, i am not sure if this should go here or in the issues of the repositories. If this is not the right place i will gladly post it on github.

I installed everything as said in github repos (tpm2-tss, tpm2-abrmd and tpm2-tools). I am trying to create an application (just a proof of concept) with tpm2 and the first thing i am trying to do is call a function from the library Esys (tss2/tss2_esys.h) to print a random number. Unfortunately, when i try to compile and link the application files the compiler/linker (gcc) says:

(if it is needed i can copy/paste the whole text)
"undefined reference to `Esys_GetRandom'"

On the code, i am trying to make the same call that is made on tpm2-tools getrandom, so i dont think there is a problem with that call (and also it compiles correctly but doesn't link).

I am using the flags i suppose are needed "-I/usr/local/include" for compilation (just to be sure) and "-L/usr/local/lib -ltss2-mu -ltss2-tcti-device -ltss2-sys -ltss2-esys" for the linking part (i also tried with the flags "-ltpm2sapi" which i found in another github repo. I was able to compile and use all the tools on the tpm2-tools repo, which makes me believe the problem is not in the libraries themselves but  any flags may be missing in my linking. Unfortunately, i tried with the flags i could get from the Makefile it has on tpm2-tools but same result.

Can anyone tell me what am i doing wrong? Or at least point me in the right direction?
The OS is Ubuntu 18.04.1 LTS (in VMWare Workstation if it makes any difference).

Thank you very much;

--
António Ribeiro
+351 916045500 | antonio.ribeiro94(a)gmail.com<mailto:antonio.ribeiro94(a)gmail.com>
Masters in Computer Science & Engineering
New University of Lisbon - Faculty of Science and Technology

[-- Attachment #2: attachment.html --]
[-- Type: text/html, Size: 4384 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [tpm2] Compiling/linking tpm2 application - undefined reference to Esys function
@ 2019-02-03  2:06 
  0 siblings, 0 replies; 4+ messages in thread
From:  @ 2019-02-03  2:06 UTC (permalink / raw)
  To: tpm2

[-- Attachment #1: Type: text/plain, Size: 1973 bytes --]

Hello everyone,

First of all, i am sorry to be bothering this mailing list with a doubt i
think it should be quite obvious unfortunately, i am not being able to find
out a solution to it. Also, i am not sure if this should go here or in the
issues of the repositories. If this is not the right place i will gladly
post it on github.

I installed everything as said in github repos (tpm2-tss, tpm2-abrmd and
tpm2-tools). I am trying to create an application (just a proof of concept)
with tpm2 and the first thing i am trying to do is call a function from the
library Esys (tss2/tss2_esys.h) to print a random number. Unfortunately,
when i try to compile and link the application files the compiler/linker
(gcc) says:

*(if it is needed i can copy/paste the whole text)*
*"undefined reference to `Esys_GetRandom'"*

On the code, i am trying to make the same call that is made on tpm2-tools
getrandom, so i dont think there is a problem with that call (and also it
compiles correctly but doesn't link).

I am using the flags i suppose are needed "-I/usr/local/include" for
compilation (just to be sure) and "-L/usr/local/lib -ltss2-mu
-ltss2-tcti-device -ltss2-sys -ltss2-esys" for the linking part (i also
tried with the flags "-ltpm2sapi" which i found in another github repo. I
was able to compile and use all the tools on the tpm2-tools repo, which
makes me believe the problem is not in the libraries themselves but  any
flags may be missing in my linking. Unfortunately, i tried with the flags i
could get from the Makefile it has on tpm2-tools but same result.

Can anyone tell me what am i doing wrong? Or at least point me in the right
direction?
The OS is Ubuntu 18.04.1 LTS (in VMWare Workstation if it makes any
difference).

Thank you very much;

-- 
António Ribeiro
+351 916045500 | antonio.ribeiro94(a)gmail.com
Masters in Computer Science & Engineering
New University of Lisbon - Faculty of Science and Technology

[-- Attachment #2: attachment.html --]
[-- Type: text/html, Size: 3115 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-02-03 19:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-03 15:23 [tpm2] Compiling/linking tpm2 application - undefined reference to Esys function 
  -- strict thread matches above, loose matches on Subject: below --
2019-02-03 19:23 Fuchs, Andreas
2019-02-03  7:22 Fuchs, Andreas
2019-02-03  2:06 

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.