Fatal error lnk1107

I am trying to load an .obj model into my c++ opengl 3 code but for some reason it gives me this error : 1>Linking... 1>.bunny.obj : fatal error LNK1107: invalid or corrupt file: cannot read at ...

I am trying to load an .obj model into my c++ opengl 3 code but for some reason it gives me this error :

1>Linking…
1>.bunny.obj : fatal error LNK1107: invalid or corrupt file: cannot read at 0x6592

I tried to search for similar errors, but there were about .dll’s or .lib’s.

Can you please help me out with this issue. I have also tried with different obj models but it always gives me this error.

asked May 4, 2013 at 10:56

user1859793's user avatar

1

You are trying to load your object model with a C++ linker (probably you have just added it to the project, and now it tries to be compiled).
The linker can process .obj files, but it waits them to be ‘object-code’ files (which also often have .obj extension), which are just compiled modules (e.g. written in C++ language) ready to be linked into a single executable or DLL.

Neither part of a C++ compiler is able to read graphical object model. You should remove the .obj file from your IDE project. And make sure you have a code that reads the file when the program runs.

If you want the object model to be embedded into your .EXE (so the program would not require the file in its directory), then you can put it into resources and link them with the executable.

answered May 4, 2013 at 11:13

nullptr's user avatar

nullptrnullptr

10.9k1 gold badge22 silver badges18 bronze badges

I had the same problem and resolved it by excluding the .obj file from the build. In other words:

  1. Right click your .obj file.
  2. Click ‘Properties
  3. Set ‘Exclude from Build’ to ‘Yes’

answered Jun 24, 2016 at 20:46

M B's user avatar

M BM B

3271 gold badge3 silver badges8 bronze badges

Содержание

  1. Ошибка средств компоновщика LNK1107
  2. Комментарии
  3. Пример
  4. Fatal error lnk1107 invalid corrupt
  5. Answered by:
  6. Question
  7. Answers
  8. All replies
  9. Fatal error lnk1107 invalid corrupt
  10. Answered by:
  11. Question
  12. Answers
  13. All replies
  14. Fatal error lnk1107 invalid corrupt
  15. Лучший отвечающий
  16. Вопрос
  17. Ответы
  18. Все ответы
  19. Fatal error lnk1107 invalid corrupt
  20. Answered by:
  21. Question
  22. Answers
  23. All replies

Ошибка средств компоновщика LNK1107

Недопустимый или поврежденный файл: не удается прочитать по адресу расположения

Средству не удалось прочитать файл. Возможно, файл поврежден или имеет непредвиденный тип файла.

Комментарии

LNK1107 может возникать, если файл, переданный компоновщику или связанным средствам, поврежден. Чтобы устранить эту проблему, перестройте файл.

LNK1107 также может возникать, если процесс сборки помещает непредвиденный тип файла в список файлов, передаваемых в средство. Компоновщик и связанные средства предполагают работу с файлами конкретного типа. Например, компоновщик может использовать объектные файлы, библиотечные файлы, скомпилированные ресурсы и манифесты для создания исполняемого файла. Он не может создать исполняемый файл с помощью исходных файлов или библиотек DLL. Чтобы устранить эту проблему, убедитесь, что процесс сборки передает в средство только ожидаемые типы файлов. Например, передайте .obj .lib файлы, и, а .res не .cpp файлы, .dll .h , или .rc .

LNK1107 также может возникать при попытке передать компоновщику исполняемый модуль .NET (файл или .netmodule , .dll созданный с помощью /clr:noAssembly или /NOASSEMBLY ). Чтобы устранить эту проблему, передайте .obj файл.

Пример

Скомпилируйте этот пример с помощью cl /clr /LD LNK1107.cpp :

Если затем указать link LNK1107.dll в командной строке, вы получите LNK1107. Чтобы устранить эту ошибку, укажите link LNK1107.obj вместо этого.

Источник

Fatal error lnk1107 invalid corrupt

This forum has migrated to Microsoft Q&A. Visit Microsoft Q&A to post new questions.

Answered by:

Question

Answers

This indicates that a file you passed into the linker is not a binary file. Check your linker command line and make sure the files being passed are recognised by the linker. You can find a list of recognised file types here. This is a signature

Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.
Visit my (not very good) blog at
http://ccprogramming.wordpress.com/

This indicates that a file you passed into the linker is not a binary file. Check your linker command line and make sure the files being passed are recognised by the linker. You can find a list of recognised file types here. This is a signature

Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.
Visit my (not very good) blog at
http://ccprogramming.wordpress.com/

The error first makes you think your hard drive is failing, but in reality this error will occur if your project must call a DLL, and you make a mistake entering the file extension.

When you set your Project/ Properties / Configuration Properties / Linker / Input / Additional Dependencies

In that space, you must state the .lib file with its path «xxx.LIB».

The «.lib» file and the entire path must be enclosed in double quotes, like:

«C:UsersmichaelDocumentsVisual Studio 2008ProjectsStatistics_Cpp_DLL_SolnDebugStatistics_Cpp_DLL_Project.lib»

If you mistakenly put the .DLL file you will get this LNK1107 error — it must be the .LIB file .

You should also put the path to the Linker / General / Additional Library Directories so that the program will find the DLL file. Enclose that path entirely in double quotes also like:

«C:UsersmichaelDocumentsVisual Studio 2008ProjectsStatistics_Cpp_DLL_SolnDebug»

Источник

Fatal error lnk1107 invalid corrupt

This forum has migrated to Microsoft Q&A. Visit Microsoft Q&A to post new questions.

Answered by:

Question

Answers

This indicates that a file you passed into the linker is not a binary file. Check your linker command line and make sure the files being passed are recognised by the linker. You can find a list of recognised file types here. This is a signature

Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.
Visit my (not very good) blog at
http://ccprogramming.wordpress.com/

This indicates that a file you passed into the linker is not a binary file. Check your linker command line and make sure the files being passed are recognised by the linker. You can find a list of recognised file types here. This is a signature

Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.
Visit my (not very good) blog at
http://ccprogramming.wordpress.com/

The error first makes you think your hard drive is failing, but in reality this error will occur if your project must call a DLL, and you make a mistake entering the file extension.

When you set your Project/ Properties / Configuration Properties / Linker / Input / Additional Dependencies

In that space, you must state the .lib file with its path «xxx.LIB».

The «.lib» file and the entire path must be enclosed in double quotes, like:

«C:UsersmichaelDocumentsVisual Studio 2008ProjectsStatistics_Cpp_DLL_SolnDebugStatistics_Cpp_DLL_Project.lib»

If you mistakenly put the .DLL file you will get this LNK1107 error — it must be the .LIB file .

You should also put the path to the Linker / General / Additional Library Directories so that the program will find the DLL file. Enclose that path entirely in double quotes also like:

«C:UsersmichaelDocumentsVisual Studio 2008ProjectsStatistics_Cpp_DLL_SolnDebug»

Источник

Fatal error lnk1107 invalid corrupt

Лучший отвечающий

Вопрос

Ответы

This indicates that a file you passed into the linker is not a binary file. Check your linker command line and make sure the files being passed are recognised by the linker. You can find a list of recognised file types here. This is a signature

Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.
Visit my (not very good) blog at
http://ccprogramming.wordpress.com/

Все ответы

This indicates that a file you passed into the linker is not a binary file. Check your linker command line and make sure the files being passed are recognised by the linker. You can find a list of recognised file types here. This is a signature

Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.
Visit my (not very good) blog at
http://ccprogramming.wordpress.com/

The error first makes you think your hard drive is failing, but in reality this error will occur if your project must call a DLL, and you make a mistake entering the file extension.

When you set your Project/ Properties / Configuration Properties / Linker / Input / Additional Dependencies

In that space, you must state the .lib file with its path «xxx.LIB».

The «.lib» file and the entire path must be enclosed in double quotes, like:

«C:UsersmichaelDocumentsVisual Studio 2008ProjectsStatistics_Cpp_DLL_SolnDebugStatistics_Cpp_DLL_Project.lib»

If you mistakenly put the .DLL file you will get this LNK1107 error — it must be the .LIB file .

You should also put the path to the Linker / General / Additional Library Directories so that the program will find the DLL file. Enclose that path entirely in double quotes also like:

«C:UsersmichaelDocumentsVisual Studio 2008ProjectsStatistics_Cpp_DLL_SolnDebug»

Источник

Fatal error lnk1107 invalid corrupt

This forum has migrated to Microsoft Q&A. Visit Microsoft Q&A to post new questions.

Answered by:

Question

Answers

This indicates that a file you passed into the linker is not a binary file. Check your linker command line and make sure the files being passed are recognised by the linker. You can find a list of recognised file types here. This is a signature

Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.
Visit my (not very good) blog at
http://ccprogramming.wordpress.com/

This indicates that a file you passed into the linker is not a binary file. Check your linker command line and make sure the files being passed are recognised by the linker. You can find a list of recognised file types here. This is a signature

Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.
Visit my (not very good) blog at
http://ccprogramming.wordpress.com/

The error first makes you think your hard drive is failing, but in reality this error will occur if your project must call a DLL, and you make a mistake entering the file extension.

When you set your Project/ Properties / Configuration Properties / Linker / Input / Additional Dependencies

In that space, you must state the .lib file with its path «xxx.LIB».

The «.lib» file and the entire path must be enclosed in double quotes, like:

«C:UsersmichaelDocumentsVisual Studio 2008ProjectsStatistics_Cpp_DLL_SolnDebugStatistics_Cpp_DLL_Project.lib»

If you mistakenly put the .DLL file you will get this LNK1107 error — it must be the .LIB file .

You should also put the path to the Linker / General / Additional Library Directories so that the program will find the DLL file. Enclose that path entirely in double quotes also like:

«C:UsersmichaelDocumentsVisual Studio 2008ProjectsStatistics_Cpp_DLL_SolnDebug»

Источник

@stellasoft-will

node_moduleselectron-rebuildlibheaders.node-gyp.36.2Releasenode.lib : fatal error LNK1107: invalid or corrupt file: cannot read at 0x153E76 [P:Documentsworktestnode_modulesffibuildffi_bindings.vcxproj]

seeing this error any ideas as to what is causing this?

@gogomarine

Same problem here.

Windows 10 ,64bit, node 6.9.5 32bit

@akshay-since1987

Same Issue. Is this fixed or we need to wait?
Windows 10 64-bit, node 7.7.1 64 bit

@LiangZheYe

Same issue, Please help us fix it.
Window 8 64-bit, node 8.4 64bit

@kimjuny

Okay… no progress guys? I just fixed MSBUILD : error MSB4132: The tools version "2.0" is unrecognized. Available tools versions are "4.0". by installing windows-build-tools package globally, and now I’m encountering this problem while yarn add ffi. Any help will be appreciated!

@krdganesh

Was facing similar issue and was getting below error —
C:UsersUserName.node-gyp8.7.0x64node.lib : fatal error LNK1107: invalid or corrupt file: cannot read at 0x34C23D [C:UsersUserNameAppDataRoamingnpmnode_modulesmcryptbuildmcrypt
.vcxproj]

After spending 10+ hours and trying random solutions / things, I deleted C:UsersUserName.node-gyp folder and did npm i to resolve dependencies, which worked for me.

One small observation, might help for other invalid or corrupt file issues on windows that try to delete the folder where the corrupt or invalid file is residing and rebuild / install again which should resolve the error.

Below are the system details —

  1. OS — Windows 10
  2. npm — 5.5.1
  3. node — v8.7.0
Quppa, dragosdydy, paaacman, AugustusWang18, oshri551, KevinLiu-AGL, dhamadkd, githoniel, huangyt39, ysrg, and 10 more reacted with thumbs up emoji
paaacman, AugustusWang18, oshri551, KevinLiu-AGL, githoniel, alex-lechner, vedant0712, NickBang, Khushbu-Desai-au5, and Hariix-Dev reacted with hooray emoji
Hariix-Dev and pacexy reacted with heart emoji

@dragosdydy

After spending 10+ hours and trying random solutions / things, I deleted C:UsersUserName.node-gyp folder and did npm i to resolve dependencies, which worked for me.

Oh my god! You saved my day! This solved my issue too! Thanks a lot!

  1. Windows 10
  2. npm — 5.6.0
  3. node — 8.9.0

@NickBang

Thank you so much for solving my problem

@weradsaoud

Was facing similar issue and was getting below error —
C:UsersUserName.node-gyp8.7.0x64node.lib : fatal error LNK1107: invalid or corrupt file: cannot read at 0x34C23D [C:UsersUserNameAppDataRoamingnpmnode_modulesmcryptbuildmcrypt
.vcxproj]

After spending 10+ hours and trying random solutions / things, I deleted C:UsersUserName.node-gyp folder and did npm i to resolve dependencies, which worked for me.

One small observation, might help for other invalid or corrupt file issues on windows that try to delete the folder where the corrupt or invalid file is residing and rebuild / install again which should resolve the error.

Below are the system details —

1. OS - Windows 10

2. npm - 5.5.1

3. node - v8.7.0

thank you man .. you are my saver .. you are God ..

@scil

Thank you.

And my target dir is C:\Users\UserName\AppData\Local\node-gyp .

Was facing similar issue and was getting below error —
C:UsersUserName.node-gyp8.7.0x64node.lib : fatal error LNK1107: invalid or corrupt file: cannot read at 0x34C23D [C:UsersUserNameAppDataRoamingnpmnode_modulesmcryptbuildmcrypt
.vcxproj]

After spending 10+ hours and trying random solutions / things, I deleted C:UsersUserName.node-gyp folder and did npm i to resolve dependencies, which worked for me.

One small observation, might help for other invalid or corrupt file issues on windows that try to delete the folder where the corrupt or invalid file is residing and rebuild / install again which should resolve the error.

Below are the system details —

  1. OS — Windows 10
  2. npm — 5.5.1
  3. node — v8.7.0

Rillaxac

Заблокирован

1

27.04.2015, 21:11. Показов 12455. Ответов 22


пытаюсь прилинковать к проекту dll-ку (она точно нормальная) пишет «fatal error LNK1107: недопустимый или поврежденный файл: не удается прочитать по 0x2B0» что бы это значило?

__________________
Помощь в написании контрольных, курсовых и дипломных работ, диссертаций здесь



0



34 / 44 / 9

Регистрация: 14.03.2015

Сообщений: 134

27.04.2015, 21:14

2

Цитата
Сообщение от Rillaxac
Посмотреть сообщение

не удается прочитать по 0x2B0″ что бы это значило?

скорее всего у тебя неподходящий фреймворк стоит



0



Rillaxac

Заблокирован

27.04.2015, 21:17

 [ТС]

3

Цитата
Сообщение от Super__Enot
Посмотреть сообщение

скорее всего у тебя неподходящий фреймворк стоит

4.5 вроде а какой нужен? разве это вообще как то влияет?



0



34 / 44 / 9

Регистрация: 14.03.2015

Сообщений: 134

27.04.2015, 21:24

4

Цитата
Сообщение от Rillaxac
Посмотреть сообщение

разве это вообще как то влияет?

конечно влияет. Но может быть проблема и в другом. Как ты пытаешься подключить dll явно или не явно?



0



Rillaxac

Заблокирован

27.04.2015, 21:26

 [ТС]

5

Цитата
Сообщение от Super__Enot
Посмотреть сообщение

конечно влияет. Но может быть проблема и в другом. Как ты пытаешься подключить dll явно или не явно?

что значит явно или не явно? через свойства проекта



0



34 / 44 / 9

Регистрация: 14.03.2015

Сообщений: 134

27.04.2015, 21:33

6

Цитата
Сообщение от Rillaxac
Посмотреть сообщение

что значит явно или не явно?

вот прочитай очень доходчиво описано. будет полезно http://rsdn.ru/article/baseserv/dlluse.xml



0



Rillaxac

Заблокирован

27.04.2015, 21:34

 [ТС]

7

Цитата
Сообщение от Super__Enot
Посмотреть сообщение

я читал уже это, мне не надо через LoadLibrary, мне надо через свойства проекта, это принципиально



0



34 / 44 / 9

Регистрация: 14.03.2015

Сообщений: 134

27.04.2015, 21:38

8

Цитата
Сообщение от Rillaxac
Посмотреть сообщение

мне надо через свойства проекта, это принципиально

а если библиотек несовместима с твоей средой разработки или написана на другом языке программирования, вы хоть об стенку расшибетесь , а ваша принципиальность вам не поможет.



0



Rillaxac

Заблокирован

27.04.2015, 21:39

 [ТС]

9

Цитата
Сообщение от Super__Enot
Посмотреть сообщение

а если библиотек несовместима с твоей средой разработки или написана на другом языке программирования, вы хоть об стенку расшибетесь , а ваша принципиальность вам не поможет.

да все она совместима я только что ее написал в этой же MSVS, на том же самом C и скомпилил это моя библиотека ! а принципиально потому что такое задание по лабе



0



34 / 44 / 9

Регистрация: 14.03.2015

Сообщений: 134

27.04.2015, 21:45

10

так надо сразу было так и писать. тогда скинь ее мне я попробую поковыряться

Добавлено через 1 минуту
только я отойду минут на 20 прийду тогда тгляну



0



Rillaxac

Заблокирован

27.04.2015, 21:49

 [ТС]

11

Super__Enot, скинул



0



34 / 44 / 9

Регистрация: 14.03.2015

Сообщений: 134

27.04.2015, 23:44

12

Цитата
Сообщение от Rillaxac
Посмотреть сообщение

dll.rar (3.6 Кб, 1 просмотров)

я посмотрел у меня все работает. ты когда подключал библиотеку создал lib файл?



0



Rillaxac

Заблокирован

28.04.2015, 13:38

 [ТС]

13

Цитата
Сообщение от Super__Enot
Посмотреть сообщение

я посмотрел у меня все работает. ты когда подключал библиотеку создал lib файл?

что? как? зачем?

Добавлено через 6 часов 10 минут
мне кажется что я просто не там ее подключаю, просто первый раз так подключал, не знал… че то нашел в гугле но видимо не то… я подключал: «проектсвойствасвойства конфигурациикомпоновщиквводдополнительные зависимости», щас глянул там какие то дефолтные есть, так вот там вроде все только lib-ы, может там нельзя dll-ки подключать по этому и ругается? тогда где можно?

Добавлено через 8 минут
я вот сейчас попробовал по тому же пути: «проектсвойствасвойства конфигурациикомпоновщиквводдобавить модуль в сборку», вроде такой ошибки больше не выдает, но ругается на мою функцию из dll-ки: «error LNK2019: ссылка на неразрешенный внешний символ __imp__MyCopyFile в функции _main», функция называлась в dll-ке MyCopyFile, я конечно понимаю бывает всякое декорирование имен, но мне кажется тут щас не в этом дело… хз в чем))



0



34 / 44 / 9

Регистрация: 14.03.2015

Сообщений: 134

28.04.2015, 18:58

14

Цитата
Сообщение от Rillaxac
Посмотреть сообщение

я конечно понимаю бывает всякое декорирование имен, но мне кажется тут щас не в этом дело… хз в чем))

большинство функций так или иначе наследуются от функций «С» там очень много функций и у многих есть в названии двойное подчеркивание



0



Rillaxac

Заблокирован

29.04.2015, 07:23

 [ТС]

15

Цитата
Сообщение от Super__Enot
Посмотреть сообщение

большинство функций так или иначе наследуются от функций «С» там очень много функций и у многих есть в названии двойное подчеркивание

где там? у меня в библиотеке всего одна эта функция и все, там нет никаких других функций… (просто смысл лабы экспортировать функцию в библиотеку и вызвать оттуда)

Добавлено через 11 часов 28 минут
хэлп !!!



0



Эксперт по математике/физикеЭксперт С++

2001 / 1332 / 379

Регистрация: 16.05.2013

Сообщений: 3,450

Записей в блоге: 6

29.04.2015, 07:35

16

Rillaxac, если это ваша dll то где исходный код?

Цитата
Сообщение от Rillaxac
Посмотреть сообщение

ругается на мою функцию из dll-ки: «error LNK2019: ссылка на неразрешенный внешний символ __imp__MyCopyFile в функции _main», функция называлась в dll-ке MyCopyFile, я конечно понимаю бывает всякое декорирование имен, но мне кажется тут щас не в этом дело… хз в чем))

Скорее всего именно в этом.



0



Rillaxac

Заблокирован

29.04.2015, 17:25

 [ТС]

17

Цитата
Сообщение от Ilot
Посмотреть сообщение

Rillaxac, если это ваша dll то где исходный код?

а он нужен? зачем?

Цитата
Сообщение от Ilot
Посмотреть сообщение

Скорее всего именно в этом.

нет я почти уверен что не в этом, dll-ка написана на чистом си а там нет декорирования имен вроде



0



Ушел с форума

Эксперт С++

16454 / 7418 / 1186

Регистрация: 02.05.2013

Сообщений: 11,617

Записей в блоге: 1

29.04.2015, 17:39

18

Цитата
Сообщение от Rillaxac
Посмотреть сообщение

dll-ка написана на чистом си а там нет декорирования имен вроде

Декорирование имен и язык программирования — вещи не связанные.
Чтобы не было декорирования, нужно применять DEF-файл для экспорта.

Добавлено через 3 минуты

Цитата
Сообщение от Rillaxac
Посмотреть сообщение

но ругается на мою функцию из dll-ки: «error LNK2019: ссылка на неразрешенный внешний символ __imp__MyCopyFile в функции _main

Компоновщику нужен .lib-файл, чтобы найти функцию MyCopyFile.
.lib-файл генерируется при создании dll.



0



Rillaxac

Заблокирован

29.04.2015, 17:51

 [ТС]

19

Цитата
Сообщение от Убежденный
Посмотреть сообщение

Декорирование имен и язык программирования — вещи не связанные.
Чтобы не было декорирования, нужно применять DEF-файл для экспорта.

что еще за хрень?

Цитата
Сообщение от Убежденный
Посмотреть сообщение

Компоновщику нужен .lib-файл, чтобы найти функцию MyCopyFile.
.lib-файл генерируется при создании dll.

кинул я ему lib все равно ругается также…

Добавлено через 2 минуты
я уже делал dll-ки, только экспортировал их сразу в шарп и все работало, без lib-ов, без декорирования, просто работало (DllImport, MarshalAs и т.д.) а вот в си первый раз экспортирую…



0



Убежденный

Ушел с форума

Эксперт С++

16454 / 7418 / 1186

Регистрация: 02.05.2013

Сообщений: 11,617

Записей в блоге: 1

29.04.2015, 18:10

20

Цитата
Сообщение от Rillaxac
Посмотреть сообщение

что еще за хрень?

Module-Definition (.Def) Files
https://msdn.microsoft.com/en-… 6s79h.aspx

Цитата
Сообщение от Rillaxac
Посмотреть сообщение

кинул я ему lib все равно ругается также…

Куда «кинул» ?
Нужно в Linker / Input прописать имя lib-файла.
Или если прямо в исходнике:

C++
1
#pragma comment(lib, "name.lib")

При этом компоновщику нужно еще прописать пути, где он
этот файл будет искать. Ну или как третий вариант, сделать проект,
который подключает dll, зависимым от проекта, в котором эта dll
собирается, тогда компоновщик подключит ее автоматически.

Цитата
Сообщение от Rillaxac
Посмотреть сообщение

я уже делал dll-ки, только экспортировал их сразу в шарп и все работало, без lib-ов, без декорирования, просто работало

Ну так и здесь все работает, просто начинать с чтения мануалов,
лучше сразу с официальной документации.



0



I followed and adapted your links :

Coding Requirements for Sharing Procedures in DLLs

Building Dynamic-Link Libraries

and

Building Executables that Use DLLs

with the following codes :

The dll code :

function mysum(x,y) result(z)
    !DEC$ ATTRIBUTES DLLEXPORT :: mysum
    INTEGER x, y
    z = x+y
    end function mysum

function myprod(x,y) result(z)
    !DEC$ ATTRIBUTES DLLEXPORT :: myprod
    INTEGER x, y
    z = x*y
    end function myprod

in dll.F90 and the client code :

program CallingTheDLL
    !DEC$ ATTRIBUTES DLLIMPORT:: mysum
    !DEC$ ATTRIBUTES DLLIMPORT:: myprod
    integer i, j

    integer resS
    integer resP

    print*,"enter two integers"
    read (*,*) i,j
    resS = mysum(i, j)

    resP = myprod(i, j)

    print*,"Sum of ",i," and ",j," is = ",resS
    print*,"Product of ",i," and ",j," is = ",resP
    
    read(*,*)
end program CallingTheDLL

in client.F90.

The structure in the folder is :

I have a folder DLL_EXAMPLE containin two folders :

  • DLL that contains dll.F90
  • CLIENT that contains client.F90

In the folder DLL I run :

ifort /align:commons /dll dll.F90

which gives to me the output :

-out:dll.dll
-dll
-implib:dll.lib
dll.obj
   Creating library dll.lib and object dll.exp

then in the CLIENT I run :

ifort /align:commons /dll client.exe ...DLLdll.obj /link ...DLLdll.dll

which gives to me the outup :

-out:client.dll
-dll
-implib:client.lib
...DLLdll.dll
client.exe
...DLLdll.obj
...DLLdll.dll : fatal error LNK1107: invalid or corrupt file: cannot read at 0x2F0

Remark : if I run

ifort -o client.exe /dll ...DLLdll.obj /link ...DLLdll.lib

instead I don’t have an error, and have this output :

-out:client.exe
-dll
-implib:client.lib
...DLLdll.lib
...DLLdll.obj
   Creating library client.lib and object client.exp

but when I double click the exe I have a windows 10 pop up «This app can’t run on your PC» and if I try to run it from the command line, I have :

C:WORKCODINGMYSHITFORTRANTOYINGDLL_EXAMPLE>.CLIENTclient.exe
Access is denied.

Adding `/align:commons` or not doesn’t change anything.

What did I do wrong and how to correct ?

Понравилась статья? Поделить с друзьями:

Читайте также:

  • Fatal error lnk1104 не удается открыть файл vcompd lib
  • Fatal error lnk1104 не удается открыть файл msvcrtd lib
  • Fatal error lnk1104 не удается открыть файл kernel32 lib
  • Fatal error lnk1104 не удается открыть файл glut32 lib
  • Fatal error lnk1104 не удается открыть файл dll

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии