Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to compile my first C program on ubuntu after installing miracl #108

Open
mrityunjaysingh1983 opened this issue Nov 18, 2021 · 4 comments

Comments

@mrityunjaysingh1983
Copy link

mrityunjaysingh1983 commented Nov 18, 2021

Please help in resolving my issues. I get the following error when I compile my C program.

gcc -I/home/mypc/Desktop/miracl/ ms.c
ms.c: In function ‘main’:
ms.c:26:1: warning: implicit declaration of function ‘cotnum’ [-Wimplicit-function-declaration]
   26 | cotnum(y, stdout);
      | ^~~~~~
/usr/bin/ld: /tmp/cckHid5T.o: in function `main':
ms.c:(.text+0x28): undefined reference to `mirsys'
/usr/bin/ld: ms.c:(.text+0x39): undefined reference to `mirvar'
/usr/bin/ld: ms.c:(.text+0x4a): undefined reference to `mirvar'
/usr/bin/ld: ms.c:(.text+0x65): undefined reference to `expb2'
/usr/bin/ld: ms.c:(.text+0x80): undefined reference to `incr'
/usr/bin/ld: ms.c:(.text+0xa0): undefined reference to `big_to_bytes'
/usr/bin/ld: ms.c:(.text+0x115): undefined reference to `bytes_to_big'
/usr/bin/ld: ms.c:(.text+0x144): undefined reference to `cotnum'
collect2: error: ld returned 1 exit status
#include <stdio.h>
#include "miracl.h"
int main()
{
int i, len;
miracl *mip = mirsys(100, 0);
big x, y;
char b[200]; // b needs space allocated to it
x = mirvar(0); // all big variables need to be "mirvar"ed
y = mirvar(0);

expb2(100, x);
incr(x, 3, x); // x = 2^100 + 3

len = big_to_bytes(200, x, b, FALSE);
// Now b contains big number x in raw binary
// It is len bytes in length

// now print out the raw binary number b in hex
for (i = 0; i < len; i++) printf("%02x", b[i]);
printf("n");

// now convert it back to big format, and print it out again
bytes_to_big(len, b, y);
mip->IOBASE = 16;
cotnum(y, stdout);

return 0;
}`
@mcarrickscott
Copy link
Contributor

mcarrickscott commented Nov 18, 2021 via email

@mrityunjaysingh1983
Copy link
Author

mrityunjaysingh1983 commented Nov 19, 2021

To install miracl in my Ubuntu system I used the following steps.

  1. Downloaded .zip file by clicking Code button which is present at the website https://github.com/miracl/MIRACL.
  2. Then created a directory named miracl on my desktop. Then executed the command unzip -j -aa -L miracl-master.zip on my miracl directory. Then typed Y and enter many times.
  3. Then executed the command bash linux64.

My program is present at /home/mypc/Desktop and name is ms.c

My miracl.h header file is present in /home/mypc/Desktop/miracl.

When I execute gcc -O2 /home/mypc/Desktop/miracl ms.c

miracl.h no such file or directory

May I know the right command to execute on my terminal if I am executing the wrong command?

If I am doing other mistakes then please let me know.

@mrityunjaysingh1983
Copy link
Author

mrityunjaysingh1983 commented Jan 7, 2022

I am facing problem in installing miracl.
I have followed the following procedure to install miracl.

  1. I have downloaded the zip folder from Code button present at github. Then unzip the folder on my Desktop. It gives MIRACL-master folder.
  2. Open terminal in directory MIRACL-master
  3. Run gcc config.c and then ./a.out. It generates miracl.tst.
  4. Renamed miracl.tst to miracl.h
  5. Now, I am not able to compile miracl.lst. As I run the command gcc –I. –c –O2 mr*.c it gives the following error.
  6. gcc: error: –I.: No such file or directory
    gcc: error: –c: No such file or directory
    gcc: error: –O2: No such file or directory
    gcc: error: mr*.c: No such file or directory
    gcc: fatal error: no input files
    compilation terminated.
    Please help in resolving this error.

@mrityunjaysingh1983
Copy link
Author

mrityunjaysingh1983 commented Feb 27, 2022

  1. Compile and run config.c on the target processor.
    Action: gcc confing.c (it gives some warning)

  2. Rename the generated file mirdef.tst to mirdef.h
    Action: mv mirdef.tst mirdef.h and then copied this file in MIRACL-master/include

3. copied the standard C version mrmuldv.ccc to mrmuldv.c and use this to compile
  1. Make sure that all the MIRACL header files are accessible to the compiler. Typically the flag –I. or /I. allows these headers to be accessed from the current directory.

Action: To ensure this I used the following command to compile gcc –I /home/mypc/Desktop/MIRACL-master/include –c –O2 mr*.c

  1. Compile the MIRACL modules listed in the generated file miracl.lst and create a library file, typically miracl.a or miracl.lib. This might be achieved by editing miracl.lst into a suitable batch or make file. On UNIX it might be as simple as:

Action: cd /home/mypc/Desktop/MIRACL-master/source; gcc –I /home/mypc/Desktop/MIRACL-master/include –c –O2 mr*.c

It gives many error. Some are as follows. Please help me in resolving these errors.

mrarth1.c:56:10: fatal error: ieeefp.h: No such file or directory
56 | #include <ieeefp.h>
| ^~~~~~~~~~
compilation terminated.
mrmonty.c: In function ‘prepare_monty’:
mrmonty.c:145:20: error: invalid operands to binary >> (have ‘mr_small’ {aka ‘double’} and ‘int’)
145 | if (n->w[n->len-1]>>M4 < 5) mr_mip->NO_CARRY=TRUE;
| ~~~~~~~~~~~~~~^~
| |
| mr_small {aka double}
mrmuldv12.c: In function ‘muldiv’:
mrmuldv12.c:7:13: error: unknown type name ‘_asm’
7 | #define ASM _asm
| ^~~~
mrmuldv12.c:12:9: note: in expansion of macro ‘ASM’
12 | ASM mov eax,DWORD PTR a
| ^~~
mrmuldv12.c:12:19: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘eax’
12 | ASM mov eax,DWORD PTR a
| ^~~
mrmuldv12.c:15:23: error: invalid suffix "h" on integer constant
15 | ASM adc edx,0h

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants