kit-cel / simulink-hackrf

Simulink blockset and MATLAB functions to interface with HackRF devices in real-time
GNU General Public License v3.0
44 stars 22 forks source link

Error using MEX #11

Open MiguelVSantos opened 6 years ago

MiguelVSantos commented 6 years ago

Hi, I've tried to compile but afeter i added the empty libhackrf.lib file i get this error:

C:\hackrf_one\simulink-hackrf-1.0\simulink-hackrf-1.0\deps\bin\libhackrf.lib: file not recognized: File truncated collect2.exe: error: ld returned 1 exit status

Error in make (line 66) mex(options{:}, 'src/hackrf_find_devices.c')

btw i'm using MATLAB R2018a any idea? regards

mpozzo commented 5 years ago

Hi, could you solve it? Regards

shanpriyan commented 5 years ago

i got the same error in MATLAB 2017b ,if you find the solution please let me know . Thanks.

AustrianCodeWriter commented 5 years ago

Hey, I had the same issue with MATLAB R2017B. The file libhackrf.lib cannot be empty, since MATLAB use it for compiling with MEX. I found a way to easily create a valid libhackrf.lib file using Microsoft Visual C++ ("MSVC"):

  1. Call a new MSVC console (e.g. for "Visual Studio 2019": Start a new command line window and call the batch-script from "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community \VC\Auxiliary\Build\vcvars64.bat")

  2. Change directory to "deps\bin\" and run: dumpbin /EXPORTS libhackrf.dll > libhackrf.exports

  3. Create a new file called "libhackrf.def" and insert the following lines:

    LIBRARY "libhackrf.dll"
    EXPORTS
    hackrf_board_id_name
    hackrf_xxx

    ... for _hackrfxxx insert each "hackrf_" element from your previously created "libhackrf.exports" file

  4. In your MSVC console type the command: lib /def:libhackrf.def /machine:x64 /out:libhackrf.lib

  5. If you now run make in MATLAB it should compile without any problems

Regards

shanpriyan commented 5 years ago

thank you for your reply

On Sun, Aug 4, 2019 at 10:44 PM AustrianCodeWriter notifications@github.com wrote:

Hey, I had the same issue with MATLAB R2017B. The file libhackrf.lib cannot be empty, since MATLAB use it for compiling with MEX. I found a way to easily create a valid libhackrf.lib file using Microsoft Visual C++ ("MSVC"):

  1. Call a new MSVC console (e.g. for "Visual Studio 2019": Start a new command line window and call the batch-script from "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community \VC\Auxiliary\Build\vcvars64.bat")
  2. Change directory to "deps\bin" and run: dumpbin /EXPORTS libhackrf.dll > libhackrf.exports
  3. Create a new file called "libhackrf.def" and insert the following lines:

    LIBRARY "libhackrf.dll" EXPORTS hackrf_board_id_name hackrf_xxx

... for _hackrfxxx insert each "hackrf_" element from your previously created "libhackrf.exports" file

1.

In your MSVC console type the command: lib /def:libhackrf.def /machine:x64 /out:libhackrf.lib 2.

If you now run make in MATLAB it should compile without any problems

Regards

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kit-cel/simulink-hackrf/issues/11?email_source=notifications&email_token=AKEQA6ZZUFRMNA6W6BDA7Y3QC4FALA5CNFSM4F7QYSZ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3QF2OA#issuecomment-518020408, or mute the thread https://github.com/notifications/unsubscribe-auth/AKEQA63GQATBIQS7GCQGVWLQC4FALANCNFSM4F7QYSZQ .