Rockbox Technical Forums

Rockbox Development => Starting Development and Compiling => Topic started by: robertdundee on December 11, 2014, 11:22:24 AM

Title: make sendfirm
Post by: robertdundee on December 11, 2014, 11:22:24 AM
In the  directory ~/rockbox/utils/MTP$ I try to create sendfirm following the instructions. I write make but I get error 1. How can I fix this>

gcc  -Wall -lmtp -o sendfirm sendfirm.c
sendfirm.c: In function ‘sendfile_function’:
sendfirm.c:78:9: warning: implicit declaration of function ‘exit’ [-Wimplicit-function-declaration]
         exit(1);
         ^
sendfirm.c:78:9: warning: incompatible implicit declaration of built-in function ‘exit’ [enabled by default]
sendfirm.c: In function ‘main’:
sendfirm.c:142:5: warning: incompatible implicit declaration of built-in function ‘exit’ [enabled by default]
     exit(0);
     ^
/tmp/cchJ6DIx.o: In function `sendfile_function':
sendfirm.c:(.text+0x11d): undefined reference to `LIBMTP_new_file_t'
sendfirm.c:(.text+0x18e): undefined reference to `LIBMTP_Send_File_From_File'
sendfirm.c:(.text+0x1c0): undefined reference to `LIBMTP_Dump_Errorstack'
sendfirm.c:(.text+0x1cf): undefined reference to `LIBMTP_Clear_Errorstack'
sendfirm.c:(.text+0x1fa): undefined reference to `LIBMTP_destroy_file_t'
/tmp/cchJ6DIx.o: In function `main':
sendfirm.c:(.text+0x227): undefined reference to `LIBMTP_Init'
sendfirm.c:(.text+0x24a): undefined reference to `LIBMTP_Get_First_Device'
sendfirm.c:(.text+0x290): undefined reference to `LIBMTP_Release_Device'
collect2: error: ld returned 1 exit status
make: *** [sendfirm] Error 1

Title: Re: make sendfirm
Post by: saratoga on December 11, 2014, 11:25:06 AM
Do you have libmtp installed? The linker can't find it.

Edit:  The wiki lists the dependencies:

Quote
The sendfirm utility is used to upgrade the firmware in an MTP device. It can be found in the utils/MTP directory in the Rockbox source tree; the Linux version requires both libusb and libmtp (and their development packages) to compile and use. This utility can be used from Linux and Windows.
For Linux: to compile, just type make in the utils/MTP directory.
For Windows: make sure you have MingW installed and type make sendfirm.exe in the utils/MTP directory (or download the binary here).

http://www.rockbox.org/wiki/GigabeatSInstallation#A_41_Compile_the_sendfirm_utility
Title: Re: make sendfirm
Post by: robertdundee on December 11, 2014, 05:21:09 PM
Thank you. Yes, I have both libusb and libmtp installed. Im stuck on this part. Any advice is greatly appreciated
Title: Re: make sendfirm
Post by: saratoga on December 11, 2014, 05:26:29 PM
Do you have the development packages too (so that would be a total of 4 packages not 2).
Title: Re: make sendfirm
Post by: robertdundee on December 11, 2014, 06:19:48 PM
Yes, i do have all the packages installed in ubuntu
Title: Re: make sendfirm
Post by: pamaury on December 13, 2014, 06:24:30 AM
You probably have an old version of gcc which cares about the order when linking.
Try to edit the Makefile (at utils/MTP/Makefile) and replace this line:
Code: [Select]
gcc $(EXTRA_CFLAGS) $(CFLAGS) $(LIBS) -o $(OUTPUT) sendfirm.cby this line:
Code: [Select]
gcc $(EXTRA_CFLAGS) $(CFLAGS) -o $(OUTPUT) sendfirm.c $(LIBS)
Title: Re: make sendfirm
Post by: robertdundee on December 13, 2014, 06:33:35 AM
Many thanks Pamaury !

~/rockbox/utils/MTP$ make
gcc  -Wall -o sendfirm sendfirm.c -lmtp
sendfirm.c: In function ‘sendfile_function’:
sendfirm.c:78:9: warning: implicit declaration of function ‘exit’ [-Wimplicit-function-declaration]
         exit(1);
         ^
sendfirm.c:78:9: warning: incompatible implicit declaration of built-in function ‘exit’ [enabled by default]
sendfirm.c: In function ‘main’:
sendfirm.c:142:5: warning: incompatible implicit declaration of built-in function ‘exit’ [enabled by default]
     exit(0);
     ^
Title: Re: make sendfirm
Post by: __builtin on December 13, 2014, 11:29:43 AM
Many thanks Pamaury !

~/rockbox/utils/MTP$ make
gcc  -Wall -o sendfirm sendfirm.c -lmtp
sendfirm.c: In function ‘sendfile_function’:
sendfirm.c:78:9: warning: implicit declaration of function ‘exit’ [-Wimplicit-function-declaration]
         exit(1);
         ^
sendfirm.c:78:9: warning: incompatible implicit declaration of built-in function ‘exit’ [enabled by default]
sendfirm.c: In function ‘main’:
sendfirm.c:142:5: warning: incompatible implicit declaration of built-in function ‘exit’ [enabled by default]
     exit(0);
     ^


Those are just minor warnings. If they really bother you, just add this line to the top of sendfirm.c:

Code: [Select]
#include <stdlib.h>
Title: Re: make sendfirm
Post by: robertdundee on December 14, 2014, 08:46:59 AM
Thanks. When I try the make sendfirm.exe Im having the following problem>
mingw32-gcc -Wall -o sendfirm.exe sendfirm_win.c MTP_DLL.dll
make: mingw32-gcc: Command not found
make: *** [sendfirm.exe] Error 127
Title: Re: make sendfirm
Post by: pamaury on December 14, 2014, 08:51:22 AM
To compile sendfirm under Windows, you need the MingGW compiler which is not super easy to install. In this case I suggest you simply use the prebuilt version: https://www.dropbox.com/s/9vwc4qdyh0c6e0p/sendfirm.exe?dl=0 (https://www.dropbox.com/s/9vwc4qdyh0c6e0p/sendfirm.exe?dl=0) (note that this link is on the wiki page...)
Title: Re: make sendfirm
Post by: robertdundee on December 14, 2014, 08:56:57 AM
Thank you Pamaury. I will do that
Title: Re: make sendfirm
Post by: gordonrgw on December 03, 2019, 09:54:27 AM
Thanks all,

I know this is 5 years later, but this sorted my make on Linux Mint 19.2 also..